tsukasa wrote:
Is there any examples for using the new OpenSessionInViewInterceptor and OpenSessionInViewFilter , particularly with Struts or JSF.
OpenSessionInViewFilter is a standard Servlet 2.3 Filter that can be used with any web tier, to be mapped in web.xml for all resources that need an open Hibernate Session in the view. For Spring's web MVC, OpenSessionInViewInterceptor is the way to go, because it can much more conveniently be mapped in a Spring HandlerMapping instead of in the otherwise unaffected web.xml file.
By default, OpenSessionInViewFilter looks up a "sessionFactory" bean in the root web application context: Obviously, it needs a SessionFactory to create thread-bound Sessions with. If your SessionFactory bean is named differently, specify a corresponding "sessionFactoryBeanName" init-param on the filter. See OpenSessionInViewFilter's javadoc for details.
Note that transactions demarcated in your business layer will still get applied as usual even with an OpenSessionInViewFilter. However, Hibernate Sessions will not be scoped per transactions but rather per request (which can potentially span multiple transactions), to be closed at the end of view rendering. This can have side effects if you have transaction recovery code or the like, although it won't in typical cases.
Juergen