hibernate/hibernate-tools — pull request #44 by karlvr (2014-05-08 06:07:56+00:00)
Title: Support proxies in generated equals(Object) implementation

The current hbm2java equals(Object) implementation doesn't work when the other object is a proxy, as there is an instanceof check that the proxy fails. I have changed this to use Hibernate.getClass(Object)... this does change the semantics of the equals implementation, but I think it's better?

This is derived from my previous pull request, so please excuse the first two commits.

Keen to discuss!

More detail…

This changes the semantics of the equals(Object) method as we compare that classes are equal, rather than the existing instanceof method. I did this because I don't think the instanceof method was the right solution, I think it should have always been ensuring the two objects were the same class.

This equals method requires that any methods used to determine equality are implemented in the proxy interface.

If you're not using proxies then then only impact is the change to compare classes rather than use instanceof.