Hibernate ID Generation - Must Read
tl;dr See here for how to properly generate equals and hashCode for Hibernate. The catch is that with Hibernate you end up with a mix of Entity class and HibernateProxy subclasses, which will not match the equals methods suggested in most places. Overview Review the article linked above for the technical details of how equals and hashCode are used by Hibernate. The key is that these need to reflect the primary key of the entity so that when Hibernate needs an object for a database record it can locate it in its session. ...