-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: idbag, equals() and hashCode()
PostPosted: Thu Apr 06, 2006 8:10 am 
Beginner
Beginner

Joined: Mon Aug 02, 2004 1:08 pm
Posts: 42
Since I'm not 100% sure that it's a bug, I'd like to ask if there is any specific reason that idbag-managed collections do not implement equals() and hashCode().
I've found out that after switching to idbags, equals() stopped working. I've checked the PersistentIdentifierBag and it seems like neither it nor its superclasses override equals() and hashCode() methods.

Is there any specific reason for that or is it a bug?
Thank you for your time.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 06, 2006 9:31 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
PersistentBag also does not implement equals with the comment:

/**
* Bag does not respect the collection API and do an
* JVM instance comparison to do the equals.
* The semantic is broken not to have to initialize a
* collection for a simple equals() operation.
* @see java.lang.Object#equals(java.lang.Object)
*/

so i think the same is applicable for idbag.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 06, 2006 9:41 am 
Beginner
Beginner

Joined: Mon Aug 02, 2004 1:08 pm
Posts: 42
Ok, thanks for the hint. I'll have to redo the collection comparison then.

ps. Maybe it's not a bad idea to add small note to the docs.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 06, 2006 9:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
put it in jira as a trivial issue then we wont forget.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 06, 2006 10:11 am 
Beginner
Beginner

Joined: Mon Aug 02, 2004 1:08 pm
Posts: 42
max wrote:
put it in jira as a trivial issue then we wont forget.


http://opensource.atlassian.com/project ... e/HHH-1642


Top
 Profile  
 
 Post subject: Re: idbag, equals() and hashCode()
PostPosted: Wed Nov 25, 2009 6:40 pm 
Beginner
Beginner

Joined: Sat Sep 17, 2005 6:50 am
Posts: 23
Can anybody please comment on this Javadoc:
Code:
The semantic is broken not to have to initialize a collection for a simple equals() operation.

I personally do not understand, why bags behave differently from lists or sets.
Opened HHH-5409.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.