I cross-posted in Javaranch too. I did my due diligence by doing Google search. I did not find any answer.
We have a REST service bases Web Application, for which backend is implemented using Groovy and Grails (1.3.7 with Groovy 1.7.x). I understand how Open Session In View works in general for Hibernate, and when configuring Hibernate with Spring, we could specify for which set of URLs, OSIV should work in the filter configuration.
The issue is I cannot find how to exclude a set of URLs from the scope of OSIV filter (like matching *.js, *.gif, etc). I found from the Hibernate log, that even for Javascript file request, Open Session In View kicks in and opens a session and closes it.
Thanks in advance.
Grails has two implementations of the OSIV pattern, GrailsOpenSessionInViewFilter
and GrailsOpenSessionInViewInterceptor
. The filter was used in earlier versions of Grails but the interceptor is now what is used (at least in 1.2, 1.3 and 2.0). Since it's a WebRequestInterceptor
it only applies to controller requests and not static requests for JavaScript, CSS, images, etc. So there's no performance concern for unnecessarily creating and binding a Hibernate session for simple file requests.
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