[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3007?page=c...
]
Gail Badner updated HHH-3007:
-----------------------------
Comment: was deleted
(was: Ugh, there was a bug in my test code. After fixing it this issue does not
reproduce.
Lars, please let me know if this is still a bug. If so, please add more details.
Thanks,
Gail)
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira