[jboss-user] [EJB 3.0] - Re: Equals and hashCode on Entities fails due to javassist

jc7442 do-not-reply at jboss.com
Mon Aug 6 04:20:59 EDT 2007


I suppose that in your equals you invoke getClass. I had the same problem. There is a Wiki on hibernate about equals and hashcode (http://www.hibernate.org/109.html).

For my entites, I never invoke getClass, I use a workaround to be sure not to have proxy. That's ugly, but I did not find something more elegant in javassist publi API.



  | public static Class getBaseClass(Class srcClass) {
  |     if (srcClass.getName().contains(CGLIB)
  |         || srcClass.getName().contains(JAVASSIST)) {
  |       return srcClass.getSuperclass();
  |     }
  |     return srcClass;
  | 
  |   }

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4071050#4071050

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4071050



More information about the jboss-user mailing list