Hi all
I have a grails service that is persisting some changes. If I rollback the transaction in the service class, throwing a RuntimeException, and later (in the same request) I try to re-read any data, I'm getting the following exception:
ERROR hibernate.LazyInitializationException - failed to lazily initialize a collection of role: <my related class> no session or session was closed
So, the case is the following:
I try to update an object, in the service class, and if it fails, I will rollback the transaction. In the controller, take care of the exception, and I return an XML of the failed object. To create the XML grails is trying to read all related objects -lazy load 1-n relationship- (that is what I want), but as we already did a rollback in the service class, I have no session, and it fails. I tried using .withNewSession {} and it does not work.
Any ideas or workaround?