[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-1525) multiple cascades to the same transient instance within a single object graph

Steve Mayhew (JIRA) noreply at atlassian.com
Thu Jan 18 13:00:45 EST 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1525?page=comments#action_25841 ] 

Steve Mayhew commented on HHH-1525:
-----------------------------------

I humbly asset that this may be an instance of this issue:
    <class name="Base">
         <many-to-one name="bar" class="Bar" not-null="true" cascade="delete" />
         ...

    <joined-subclass name="A" extends="Base">
        ...

    <joined-subclass name="B" extends="Base">
        ...

Hibernate delete,
    List list  = session.createCriteria(Base.class).list();
    for (Iterator it = list.iterator(); it.hasNext();) {
	 session.delete(it.next());
    }

This will throw a  org.hibernate.PropertyValueException: not-null property references a null or transient value.

Am I missing something?



> multiple cascades to the same transient instance within a single object graph
> -----------------------------------------------------------------------------
>
>          Key: HHH-1525
>          URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1525
>      Project: Hibernate3
>         Type: Improvement

>   Components: core
>     Reporter: Steve Ebersole
>     Assignee: Steve Ebersole

>
>
> Consider an object graph being saved that contains the same transient instance multiple times (at diffierent levels in the graph) where some of the associations define cascading and some do not and that the associations without cascading are further defined as not-null.  Based on the order in which the associations are cascaded there is a potential for that transient instance to cause an "unsaved transient instance" exception if the non-cascaded and not-null association is cascaded to first, even though a subsequent cascaced would in fact cause the instance to become managed.
> Typically this is easy enough to work around by simply reordering the associations in the mapping so that the cascaded association is before the non-cascaded one.  However, this is not always possible (the case of inheritence hierarchies comes to mind, where the superclass associations are always cascaded to first).

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list