views:

27

answers:

1

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.

+2  A: 

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.

Burt Beckwith