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
|