hibernate 问题集

时间:2022-02-17 14:30:52

1、Could not obtain transaction-synchronized Session for current thread

解决方法:

在web.xml中加入如下配置:

 <filter>
<filter-name>SpringOpenSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>SpringOpenSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>