Using OpenSessionInViewInterceptor with Hibernate and JSF 2
- by sammy
I'm building an application in Hibernate, Spring and JSF2 using only annotations. How can I take advantage of OpenSessionInViewInterceptor found in Spring to catch any hibernate session that might open within a bean?
I'm trying to elegantly solve the common “failed to lazily initialize a collection of role: your.Class.assocation no session or session was closed.” problem when trying to read from a yet uninitialized list of POJOs inside another POJO (A Tag entity retrieved by a DAO that contains a List of Project objects I want to read). I've found this:
http://www.paulcodding.com/blog/2008/01/21/using-the-opensessioninviewinterceptor-for-spring-hibernate3/
but failed to make use of it in my environment.
Please provide a detailed answer, as the Internet is full of foggy, unhelpful tutorials. I'll also be greatful for an alternative solution, given a step-by-step instruction is provided.