• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate and EnhancerbyCGlib classes

 
jay vas
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys :


Im using a reflection based jtable for an app. It looks at beans and displays their property values.

Im having a strange issue here - there are my class (call it JaysClass is somehow turned into a psuedo class by something that hibernate does under the hood. i.e. when I call getClass() it returns
JaysClass$$EnhancerByCGLIB$$66ab1395_2.

What exactly is hibernate doing to my domain objects ? This is messing up
my bean table !
 
Dan Howard
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure exactly what Hibernate does - you'd have to check their technical docs or look at the code.

Most ORM tools convert POJOs into a format which is more suitable for persisting in SQL. Basically they convert your setters to track which properties get changed so they can decide on the field list to include in the insert and update statements. Probably they do other things as well.

If you're using classname for a condition, you could use the string.startsWith() instead of equals.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CGLib is a code generation library (see here). Hibernate uses it for a bunch of reasons, the most common is to generate proxy classes on the fly. What you are probably seeing is the proxy, not the object itself. Try interogating the proxy for a property called "persistentEntity" (I think) - that is your actual POJO class. Look at your class in a debugger - thats the quickest way to see what's going on.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic