-->
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.  [ 6 posts ] 
Author Message
 Post subject: Removing CGLib Enhancement from hibernated Objects
PostPosted: Mon Mar 27, 2006 7:45 am 
Newbie

Joined: Mon Mar 27, 2006 7:13 am
Posts: 3
Hello,

I am building an XML Serialization toolkit with a hibernate backend. We use simple runtime serialisation (XStream) without any schema files. When we try to serialize hibernated objects from query Results these objects are "more" than simple pojos. They habe been enhanced by the cglib framework to become hibernated. XStream serializes the full object tree of an object. For our situation this means that we get XML Elements like "isdirty" and "PersistentCollections" instead of Lists and so on...

At the moment we iterate through each object end copy the properties directly into a new "clean" pojo of the same type. This is kind of painfull and performance decreasing - especially within hierachies of large objects.

So finally here is my question: Can I disenhance a hibernated Object? Is there any possibility to remove the cglib Enhancement from a hibernated Object via the cglib oder hibernate API?

Thank you for listening.


Sven Hohlfeld


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 27, 2006 10:29 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
Hi,

you can turn off cglib enhancement using the file hibernate.properties containing one of the following lines (depending in your hibernate version):

Code:
#hibernate.cglib.use_reflection_optimizer=false
hibernate.bytecode.use_reflection_optimizer=false


Hope this helps.

_________________
dont forget to rate !


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 27, 2006 10:32 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Don't use lazy/proxy entities.
Collections are not CGLIB enhanced - they are simple Hibernate Collections API impls.


Top
 Profile  
 
 Post subject: Lazy Proxies
PostPosted: Mon Mar 27, 2006 10:46 am 
Newbie

Joined: Mon Mar 27, 2006 7:13 am
Posts: 3
In every mapping file I use lazy=false. The problem exists though


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 27, 2006 10:58 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Each collection holds a reference to the Session.
Maybe there's your problem.


Top
 Profile  
 
 Post subject: Session -
PostPosted: Mon Mar 27, 2006 11:06 am 
Newbie

Joined: Mon Mar 27, 2006 7:13 am
Posts: 3
Well this is one of the problems. While the simple objects get hibernated the cglib does a bytecode enhancement which completly alters the objecttree. The pojos still have the interface but under the hood there is more. This "more" is not needed during the serialization. I want to get rid of it. Maybe I should post an example of the resulting xml here?


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