Equals and HashCode | Hibernate | JBoss Community - 0 views
-
best strategies for implementation of equals() and hashcode() in your persistent classes
-
The general contract is: if you want to store an object in a List, Map or a Set then it is an requirement that equals and hashCode are implemented so they obey the standard contract as specified in the documentation
-
Why are equals() and hashcode() importantNormally, most Java objects provide a built-in equals() and hashCode() based on the object's identity; so each new() object will be different from all others.
- ...8 more annotations...
-
recommend using the "semi"-unique attributes of your persistent class to implement equals() (and hashCode()
-
The database identifier property should only be an object identifier, and basically should be used by Hibernate only
-
Instead of using the database identifier for the equality comparison, you should use a set of properties for equals() that identify your individual objects