This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have mapped class that has lazy-fields. I retrieve object of this class from DB and close hibernate session. But I also use JAXB, that serializes object and tries to access the lazy collection. So I get LazyInitializationException.
How can I solve this problem?
1. Use JAXB to serialize BEFORE you close the Hibernate session.
2. Make sure that Hibernate has loaded the entire object graph that is to be serialized by JAXB BEFORE closing the Hibernate session.
Joined: Aug 17, 2009
Thanks, but both approaches are all about loading entire objects and I cannot do that - it is very expensive operation.