I stumbled on the same problem. The way I fixed is was to change the .equals
-method.
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (!getClass().isAssignableFrom(obj.getClass()))
return false;
AbstractEntity other = (AbstractEntity) obj;
if (getId() == null) {
if (other.getId() != null)
return false;
} else if (!getId().equals(other.getId()))
return false;
return true;
The trick is to not compare the classes to be the same but use the isAssignableFrom
-method. The other trick is to not use direct properties (other.id
), but use the get-method (other.getId()
)