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