[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3007) Unchanged persistent set gets marked dirty on session.merge()

Lars Koedderitzsch (JIRA) noreply at atlassian.com
Tue Feb 16 03:26:36 EST 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3007?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=35576#action_35576 ] 

Lars Koedderitzsch commented on HHH-3007:
-----------------------------------------

The code in CollectionType.replace/replaceElements seems unchanged between 3.2.5 and 3.3.2, so I suppose the problem is still there.
However, in my code I didn't find the usage of immutable collections anymore, seems at some point in the last 2 years I removed that construct.

I'll try to come up with a synthetic test case.

> Unchanged persistent set gets marked dirty on session.merge()
> -------------------------------------------------------------
>
>                 Key: HHH-3007
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3007
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.5
>            Reporter: Lars Koedderitzsch
>
> Persistent sets are marked dirty on session.merge() even if there have been no changes to the collection.
> This is especially painful when the collection is immutable and results in an "changed an immutable collection instance" exception on flush.
> I tracked the behaviour down a bit and believe the problem to be in CollectionType.replace().
> Here the passed in orginal PersistentSet is replaced by a plain HashSet in this line: 
> Object result = target == null || target == original ? instantiateResult( original ) : target;
> The "result" object (HashSet) is then passed to the CollectionType.replaceElements() method (instead of the original PersistentSet).
> In CollectionType.replaceElements() the code to clear the dirty state of the collection does not execute anymore, because the passed-in "original" collection is the described HashSet and *not* the original PersistentSet.
> This way the PersistentSet remains marked dirty.
> A workaround is to manually clear the dirty state of an immutable collection after merge but before flush.

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