-->
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.  [ 2 posts ] 
Author Message
 Post subject: PersistentSet.equals() returns false even if objects within
PostPosted: Fri Sep 08, 2006 5:11 am 
Newbie

Joined: Thu Mar 30, 2006 2:54 am
Posts: 11
Hi, I have mapped Set as collection within the beans. I have two sets (instances of PersistentSet) and one object within each. These object returns true for method obj.equals(obj2), but when I call set.equals(set2) it return false... It same returns for methods set.contains(), containsAll
Is it some strange behaving?
radim


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 08, 2006 9:11 am 
Regular
Regular

Joined: Fri May 12, 2006 4:05 am
Posts: 106
Hi,

the API-specification for Set states:
Quote:
Returns true if the specified object is also a set, the two sets have the same size, and every member of the specified set is contained in this set (or equivalently, every member of this set is contained in the specified set).

So the Set's content is compared using object-identity, not the equals()-method.
contains() states this even clearer:
Quote:
More formally, returns true if and only if this set contains an element e such that (o==null ? e==null : o.equals(e)).

So you will only get equal Sets if obj == obj2, not if obj.equals(obj2).


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.