I have one BaseEntity which abstracts id and version property. this class also implements hashcode and equals based on PK (id) property.
BaseEntity{ Lo
You can also make it works this way, usefull if you don't know wich instance is B (may happen if your equals is in a superclass)
equals
if (HibernateProxyHelper.getClassWithoutInitializingProxy(this) != HibernateProxyHelper.getClassWithoutInitializingProxy(obj)) return false