Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I care about Open Session in View when using Grails?

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.

like image 437
Vladimir Avatar asked Jul 14 '10 09:07

Vladimir


1 Answers

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.

like image 139
Burt Beckwith Avatar answered Oct 14 '22 08:10

Burt Beckwith