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

Bjarne Saebuck (JIRA) noreply at atlassian.com
Wed Mar 28 05:42:49 EDT 2012


    [ https://hibernate.onjira.com/browse/HHH-3799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=46098#comment-46098 ] 

Bjarne Saebuck commented on HHH-3799:
-------------------------------------

+1 As somebody posted before we also have two different identifiers: The "normal" primary key which is a numeric sequence value and a generated GUID which is used on Java side to guaranty uniqueness of newly created objects after transfer them from client to server and vice versa. 
So the GUID is taken to generate the HashCode. On database side the GUID of course is a column with an unique constraint but we can not take this as primary key because the customer would have his problem with "handling" such a long id. 

At debugging we saw that first time hashCode is called, the id is already known but no other fields, so wouldn´t it solve the problem if we could tell hibernate to also load the GUID field (or what field ever...) when it loads the id so that GUID is known at the same time as the id and can be used to generate the hashcode? Is there already any way to do so?

> PersistentSet does not honor hashcode/equals contract when loaded eagerly
> -------------------------------------------------------------------------
>
>                 Key: HHH-3799
>                 URL: https://hibernate.onjira.com/browse/HHH-3799
>             Project: Hibernate ORM
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.3.1, 3.5.1
>            Reporter: Igor Vaynberg
>            Assignee: Gail Badner
>         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.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the hibernate-issues mailing list