From my experience of using spring MVC in conjunction with hibernate I know about lazy exception problem occured when addressing to lazy-fetched collection when rendering view.
It pure spring+hibernate world it fixes by introducing OpenSessionInViewInterceptor
or OpenSessionInViewFilter
thus enabling one hibernate session per request.
So the question is: should I care about this problem in grails or such one-session-per-request behaviour is enabled by default.
If this isn't grails defaults please provide some code to implement this behaviour.
Thanks.
Grails registers a customized subclass of OpenSessionInViewInterceptor (it adds WebFlow awareness). So anything done in the context of a web request will have an open session and lazy-loaded references and collections will resolve.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With