session 关闭问题
[ERROR,LazyInitializationException,http-8080-1] failed to lazily initialize a collection of role: com.goodwill.basic.entity.Person.cardList, no session or session was closed
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.goodwill.basic.entity.Person.cardList, no session or session was closed
在web.xml中加入下列配置
<!-- 保证session不会关闭-->
<filter>
<filter-name>openSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
<init-param>
<param-name>singleSession</param-name>
<param-value>true</param-value>
</init-param>
<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>