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

Gail Badner (JIRA) noreply at atlassian.com
Tue May 11 13:23:26 EDT 2010


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

Gail Badner commented on HHH-3799:
----------------------------------

I've added a "FailureExpected" test that reproduces this issue to trunk and Branch_3_5: org.hibernate.test.collection.set.PersistentSetNonLazyTest.testLoadChildCheckParentContainsChildCacheFailureExpected()

The partial solution would probably involve making changes to:
- TypeFactory.assemble(...)
- various implementations of Type.assemble(...)

In response to Paul's questions:

> To the issue's original description, can hashCode() be delayed until the object is materialized? 

I'm not sure, but this could be a chicken-and-egg problem.

> Probably not feasible, but can the object be rehashed upon materialziation?

It may be possible to collect loaded entities in an EventCache then replace collection elements using CollectionType.replace(...), but I really have not looked into this. You can see examples of how these are used in DefaultMergeEventListener.

It would help a lot if someone would take a shot at implementing a fix.

Thanks,
Gail


> 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, 3.5.1
>            Reporter: Igor Vaynberg
>            Assignee: Gail Badner
>             Fix For: 3.5.x, 3.6
>
>         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