-->
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.  [ 5 posts ] 
Author Message
 Post subject: HQL join fetch and $EnhancerByCGLIB$ issue
PostPosted: Wed May 17, 2006 4:52 am 
Newbie

Joined: Wed May 17, 2006 4:32 am
Posts: 16
if to specify explicitly the <class name="ClassName"... lazy="false">
then after executing HQL query the retrieved objects are not proxied by CGLIB

but if the <class name="ClassName" ... lazy="true"> then after the hql with 'fetch join' execution i get the instance of ClassName$EnhancerByCGLIB$121212

'join fetch' shouldn't use proxy, but id does. Of course it returns initialized proxy but the className is not the original name.

the problem with the CGLIB arises when you use the retrieved proxied object in reflection API operations (for instance, while building JDOM element)
Code:
org.jdom.IllegalNameException: The name "CaseLastEvent$$EnhancerByCGLIB$$168bdef7"
is not legal for JDOM/XML elements:
XML names cannot contain the character "$".

so the main buggish point i think is because if it returns initialized proxy then that means you cant emulate the lazy="false" at runtime.
Any suggestion?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 17, 2006 5:02 am 
Regular
Regular

Joined: Wed Aug 25, 2004 6:23 am
Posts: 91
I could be wrong, but I think that's the correct behaviour - I think that the HQL join fetch just tells hibernate to fetch the keys for the collection members if the member class itself is lazy.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 17, 2006 5:15 am 
Newbie

Joined: Wed May 17, 2006 4:32 am
Posts: 16
r1ch wrote:
I think that's the correct behaviour


If this is the case then how to safely extract the original object out of CGLIB wrapper?


Last edited by jaya123 on Wed May 17, 2006 6:12 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed May 17, 2006 5:17 am 
Regular
Regular

Joined: Wed Aug 25, 2004 6:23 am
Posts: 91
Something like this should do it:-


Code:
if (proxy instanceof HibernateProxy){
   return ((HibernateProxy)proxy).getHibernateLazyInitializer().getImplementation();
}


Hope that helps.
Cheers,
Rich.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 17, 2006 5:41 am 
Newbie

Joined: Wed May 17, 2006 4:32 am
Posts: 16
r1ch wrote:
Hope that helps.


Thanks a lot dear Rich, it helped perfectly well!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.