[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3799) PersistentSet does not honor hashcode/equals contract when loaded eagerly

Oliver Meyn (JIRA) noreply at atlassian.com
Wed Oct 21 16:12:49 EDT 2009


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

Oliver Meyn commented on HHH-3799:
----------------------------------

This is proving painful for us - we typically fetch an object, serialize it, and send it off via JMS.  When an object that contains a collection gets deserialized on the other end, it goes boom due to this bug.  So we're using the return new HashSet(originalSet) workaround which "solves" the messaging problem.  

But when work has to happen close to the db and the object (say User has a field called name, and has a collection of Addresses) gets updated (updating only name) Hibernate looks at the collection and sees an entirely new object, so deletes the old collection and writes a new one, even though the data (the Addresses) are all the same.  This forces a bunch of unnecessary work in the db.

So +1 on upgrading to Major.

> PersistentSet does not honor hashcode/equals contract when loaded eagerly
> -------------------------------------------------------------------------
>
>                 Key: HHH-3799
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3799
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.3.1
>            Reporter: Igor Vaynberg
>            Assignee: Gail Badner
>            Priority: Minor
>         Attachments: test.zip
>
>
> when persistent set is loaded eagerly in some situations it calls hashcode on its items before their field values are populated and then uses this incorrect hashcode to store them in the set. this makes set items inaccessible by any collection items that rely on hashcode such as contains(), remove(), etc.
> attached is a simple maven test project that reproduces the error, unzip and mvn test to run the test.

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