1 Reply Latest reply on May 5, 2009 5:45 AM by Max Rydahl Andersen

    equals() hashcode() generation feature request

    Damian Harvey Master

      Using the default Eclipse "Generate hashcode() and equals()" from the Source menu gives you these two methods but generated using fields rather than getters.

      As Hibernate uses Proxy objects and only loads the actual object when a getter is encountered, these generated methods can prove problematic (eg. when comparing two identical entities for equality and if one is a proxy generated by CGLIB then they will not be equal as the proxied entity is not loaded via field access).

      See here http://blog.xebia.com/2008/03/08/advanced-hibernate-proxy-pitfalls/ for an explanation.

      The Eclipse templates for this generation aren't accessible, so it would be handy if there was an option to create these methods with getters via the Hibernate Eclipse plugins that are part of the Jboss Tools.

      Thanks,

      Damian.