-->
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.  [ 1 post ] 
Author Message
 Post subject: strange behavior in equal method
PostPosted: Thu Nov 25, 2004 6:51 am 
Regular
Regular

Joined: Tue Oct 12, 2004 9:02 am
Posts: 66
Location: Italy
I have a many-to-many association resolved in 1 one-to-many association and the linking class as 2 many-to-one association (i don't need the association from the second class to the linknig class..maybe is this the problem?).

I mapped the collection with cascade="all-delete-all-orphan"

but when i remove an element it is not removed. Instead it works well with insert.
So I checked the equal method in linking class.
I implemented it so:

public boolean equals(Object obj) {
if (obj == null) {
return false;
}
Preferito o = (Preferito) obj;
boolean eq = utente.equals(o.utente) &&
normativa.equals(o.normativa);
return eq;
}

And logging I discovered that this method return always false!
utente.equal(o.utente) perform an equal on username, and it return true if the usernames are equal, so ok.

Instead normativa.equals(o.normativa) perform a check only on the ID (it is an integer) and alsways return FALSE! why?
I know that usually we shouldn't use id equality, but Normativa class is not mutable, so I thought is wasn't a problem to check only the ID.
Am i wrong?


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

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.