[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-2764) EntityType.deepCopy needs to copy for EntityType.DOM4J

John Verhaeg (JIRA) noreply at atlassian.com
Wed Sep 29 14:56:57 EDT 2010


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

John Verhaeg updated HHH-2764:
------------------------------

    Fix Version/s: 4.x

Looks like the issue is due to the bidirectional relationship between DOM parent and child elements.  For POJOs, this isn't usually an issue since the component "value" is just also set as a property on the copied parent class, without being removed from the parent in the query results (technically violating composition rules, but the state of these copies is all we really care about).  For all modes, property values are simply returned rather than copied, but in the case of DOM (and I suspect also Map of Maps) adding the value to the copied parent also detaches that value from its previous parent, thus "stealing" it from the actual results.  The best way to address this is probably via entity-mode specific code for a deepCopy method introduced to the tuplizer that would actually create a copy of the value, but since that would introduce a breaking change to the tuplizer spi, this is being re-targeted for 4.x.

> EntityType.deepCopy needs to copy for EntityType.DOM4J
> ------------------------------------------------------
>
>                 Key: HHH-2764
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2764
>             Project: Hibernate Core
>          Issue Type: Bug
>    Affects Versions: 3.2.2
>         Environment: Hibernate 3.2.2
>            Reporter: Alan Krueger
>             Fix For: 4.x
>
>
> Using DOM4J with a set of composite-elements that contains a many-to-one.  When loading this from the database, the many-to-one piece of the composite-element is disappearing from the XML.  I can see the collection being built and the properties on the elements of the collection being set, but the many-to-one property disappears after that.
> Investigating this, it looks like when PersistentElementHolder.getSnapshot is called and a deepCopy is performed, the EntityType.deepCopy method returns the value to be copied rather than copying it.  This interacts poorly with the DOM4J tree, since each Element can only have a single Element parent.  When the properties are set on this, a detach is performed that yanks the original element out of its parent.

-- 
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