Should I write equals() and hashCode() methods in JPA entities?
Not necessarily. There are three options: don’t override – thus you will be working with instances. This is fine in cases when you are working with the collections with only entities that are attached to the session (and hence guaranteed to be the same instance). This is (for me) the preferred way in many cases, … Read more