That can happen if the equals()
method of your EntityType
class is missing or broken. Given the fact that you've an id
property in your EntityType
class which seems to identify the instance uniquely enough, the following minimal implementation should do it for you:
@Override
public boolean equals(Object other) {
return (other instanceof EntityType) && (id != null)
? id.equals(((EntityType) other).id)
: (other == this);
}
@Override
public int hashCode() {
return (id != null)
? (this.getClass().hashCode() + id.hashCode())
: super.hashCode();
}
hashCode()
is just mandatory as per equals()
contract.