Implement equals() and hashCode() for entities