Artem's blog

Thoughts on software

equals

Some approach for writing equials() and hashCode()

The problem described in details in http://www.hibernate.org/109.html The problem is that if we implement equals()/hashCode() as comparison and hashCode() of entity’s ids (see http://djeang.blogspot.com/2005/08/override-equals-and-hashcode-methods.html) then the hashCode() (and, possibly, equals()) will change after saving entities if ids are generated by DB. To solve this issue I can suggest to use inner classes with equals()/hashCode(). It […]

, , , , ,