我是Spring新手,想使用OpenSessionInView
,所以我不必实现Filter
。
file web.xml
<!-- openSessionInView SpringMVC -->
<filter>
<filter-name>OpenSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
<init-param>
<param-name>sessionFactoryBeanName</param-name>
<param-value>sessionFactory</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>OpenSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- FIM openSessionInView SpringMVC -->
即使将OpenSessionInView
声明放在web.xml文件中,系统也会在我使用fetch=FetchType.LAZY
Exception returned
type Exception report
message org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.pedidos.entities.Representante.listUser, no session or session was closed
感谢