Extract correct class from hibernate object wrapped with javassist

21 / Sep / 2012 by Sachin Verma 1 comments

Hi,

Some times when we access domain objects of collections in one to many or many to many relationships, we get Hibernate class wrapped with javassist, basically hibernate wraps all loaded objects with javassist after loading(lazy loading case) them .

So if  we call  class.name on the members of collections in one to many or many to many relationships we would get class names something like com.test.classname_javassist_59.

So to solve this issue, hibernate provides a HibernateProxyHelper class that has a static method to return the class without the wrapped javassist .

HibernateProxyHelper.getClassWithoutInitializingProxy(object)


This method returns the class  without the  javassist proxy of hibernate class. If the wrappedClassObject is not proxied by javassist the original class will be returned. :)


Regards
$achin verma
sachin.verma@intelligrape.com

FOUND THIS USEFUL? SHARE IT

comments (1 “Extract correct class from hibernate object wrapped with javassist”)

Leave a comment -