-->
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.  [ 1 post ] 
Author Message
 Post subject: Disabling lazy loading at runtime
PostPosted: Wed Jun 24, 2009 6:27 am 
Newbie

Joined: Wed Jun 17, 2009 5:01 am
Posts: 5
Dear all,
I'm using Hibernate + XStream to serialize objects to XML files. All had always gone well until I decided to take more advantage of Hibernate's lazy loading: that's when my problems started.

I'm keeping on getting LazyInitializationExceptions ("no session") on some field attributes, despite a session having been explicitly open just before serializing the entire object, so I guess it's probably being closed somewhere in XStream's code, which I don't have (and don't want to have) any control over.

I've made many attempts with other libraries but to no avail; furthermore, I've also explored the route of replacing uninitialized entities with null values ("unproxying"), but I don't like this approach because this means leaving out meaningful information. Rather, I'd like the lazy objects to be replaced with their non-lazy counterparts.

So, I'd say that the easiest, most intuitive solution would be to completely disable Hibernate's lazy loading feature, much as if I put "lazy=false" everywhere in the mapping files, but of course at runtime by making some call to the API.

Surprisingly enough, I haven't found any (reasonably easy) way to do this. Any help on this subject will be greatly appreciated.

Thanks in advance,
Emmanuele


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

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.