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

Nate Clark (JIRA) noreply at atlassian.com
Thu Feb 23 14:00:48 EST 2012


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

Nate Clark edited comment on HHH-3799 at 2/23/12 1:00 PM:
----------------------------------------------------------

Shawn, if I understand your scenario correctly, the PK is the Hibernate ID, and the UUID is a persistent, non-ID property. Why not use PK.hashCode() as the hashCode() of the containing object, and leave the UUID out of hashcode calculation? Wouldn't that make you immune to the problem described here?

I think any challenges relating to the lack of an ID in an unsaved entity are unrelated to this issue - please correct me if I'm mistaken.

      was (Author: nate.clark):
    Shawn, if I understand your scenario correctly, the PK is the Hibernate ID, and the UUID is a persistent, non-ID property. Why not use PK.hashCode() as the hashCode() of the containing object, and leave the UUID out of hashcode calculation? Wouldn't that make you immune to the problem described here?

I think any challenges relating to the lack of an ID in an uninitialized entity are unrelated to this issue - please correct me if I'm mistaken.
  
> 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