I agree - there's no need to provide general implementation of
equals() and hashCode() for entities. You don't event need them for
unit testing.
@Marcin sameIdentity() along with sameValue() (for VO) is a nice
addition. Even though equals() for VO is safe - it makes explicit in
your code how do you want to compare. I don't consider overriding
equals and hashCode in @Entity bad altogether as long as you don't use
JPA id in there but a business ID(entities) or other fields(VO)
instead. Thanks for pointing it out early!
@Maciej I haven't tried Pojomatic but from what I know about Lombok
and similar solutions (like apache-lang EqualsBuilder) there might not
be a place for them in entities, but they fit greatly for comparing
Value Objects
> <
http://projectlombok.org/>