-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Determine if class is initialized
PostPosted: Wed Jul 18, 2007 11:38 am 
Beginner
Beginner

Joined: Thu Apr 12, 2007 10:38 am
Posts: 22
Hi

I need to examine a graph of objects that Hibernate has given me, and determine if any objects in the graph are proxied. E.g. the value returned by getClass().getName() contains the string "$EnhancerByCGLIB$"

My session is closed at the point when I examine them (I'm marshalling the graph into XML).

I was wondering what the best way to determine if I'm looking at a proxied object is. I have a couple of ideas:

1) LazyInitializer.isUninitialized() // but my session is closed
2) ...cglib..Proxy.isProxyClass() // this always seems to return false though
3) see if the class name contains the string "$EnhancerByCGLIB$" // messy

Please could someone suggest what I should do?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 18, 2007 11:59 am 
Beginner
Beginner

Joined: Thu Apr 12, 2007 10:38 am
Posts: 22
Just tried this from within my session BTW:

Code:
if(((HibernateProxy)product.getProductStatus()).getHibernateLazyInitializer().isUninitialized()) {           ((HibernateProxy)product.getProductStatus()).getHibernateLazyInitializer().initialize();
//product.getProductStatus().getLabel();
}


This is done from within my session. The productStatus variable is always a proxied object, even after I have initialized and/or touched it (commented out line)

Code:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 19, 2007 4:05 am 
Beginner
Beginner

Joined: Fri Nov 24, 2006 10:33 am
Posts: 42
Can anyone help me with this please?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.