[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5409) bag and idbag should implement equals() and hashCode() the same way as other collections

Martin Burger (JIRA) noreply at atlassian.com
Thu Dec 1 12:04:23 EST 2011


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

Martin Burger commented on HHH-5409:
------------------------------------

There is a corresponding question on Stack Overflow: http://stackoverflow.com/questions/8344538/how-to-persist-class-that-depends-on-internal-list-using-hibernate

> bag and idbag should implement equals() and hashCode() the same way as other collections
> ----------------------------------------------------------------------------------------
>
>                 Key: HHH-5409
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5409
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.3.1
>            Reporter: Dmitry Katsubo
>
> bags/idbags behave in inconsistent way in comparison to set/list/map in respect to {{equals()}} and {{hashCode()}}.
> In {{[PersistentBag.java|http://fisheye.jboss.org/browse/Hibernate/core/trunk/core/src/main/java/org/hibernate/collection/PersistentBag.java?r=HEAD#l510]}} {{equals()}} and {{hashCode()}} methods are commented and in {{[PersistentIdentifierBag.java|http://fisheye.jboss.org/browse/Hibernate/core/trunk/core/src/main/java/org/hibernate/collection/PersistentIdentifierBag.java?r=HEAD]}} not present.
> {{[PersistentMap.java|http://fisheye.jboss.org/browse/Hibernate/core/trunk/core/src/main/java/org/hibernate/collection/PersistentMap.java?r=HEAD#l449]}}, {{[PersistentSet.java|http://fisheye.jboss.org/browse/Hibernate/core/trunk/core/src/main/java/org/hibernate/collection/PersistentSet.java?r=HEAD#l428]}}, {{[PersistentList.java|http://fisheye.jboss.org/browse/Hibernate/core/trunk/core/src/main/java/org/hibernate/collection/PersistentList.java?r=HEAD#l484]}} however implement {{equals()}} and {{hashCode()}} methods correctly.
> The intention of this is clear: to avoid loading of the lazy collection on simple {{equals()}} call.
> * I think that it is a task for the end application to handle lazy collections as it is aware about this situation.
> * If there is a strong demand of not loading collections on {{equals()}} call for some applications, I suggest to make this behaviour configurable via additional attribute in XML mapping for all collections.
> * The behaviour should be documented as suggested in HHH-1642. I personally spend hours debugging before I understood why lists behave differently from bags.
> Probably relative issues:
> * HHH-3771 ({{equals()}} for lazy loaded objects)
> * HHH-1642 ({{equals()}} for {{[AbstractPersistentCollection.SetProxy|http://fisheye.jboss.org/browse/Hibernate/core/trunk/core/src/main/java/org/hibernate/collection/AbstractPersistentCollection.java?r=HEAD#l636]}}) 

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