Do I have to take care of opening a session in view mode when using Grails?

From my experience using spring MVC in conjunction with hibernate, I know about the lazy exception problem that occurs when accessing a lazy collection when rendering a view. This is the pure world of spring + hibernate, which it fixes by introducing an OpenSessionInViewInterceptor or OpenSessionInViewFilter , thereby allowing one hibernation session for each request.

So the question is, should I take care of this problem in grails, or by default for one session per request.

If this is not the default grails, provide code to implement this behavior.

Thanks.

+6
spring model-view-controller session grails
source share
1 answer

Grails registers an individual subclass of OpenSessionInViewInterceptor (it adds WebFlow awareness). This way, everything that is done in the context of the web request will have an open session, and lazy downloadable links and collections will be allowed.

+6
source share

All Articles