首页 > 技术文章 > No Hibernate Session bound to thread, and configuration does not allow creat

my-king 2015-11-02 17:33 原文

No Hibernate Session bound to thread, and configuration does not allow creat

今天遇到这么一个错误,在网上差了很多都没有能解决我的问题。transactional注解也添加了,各种配置也都没问题,结果快纠结死了。

最终在一个回复里面发现,原来是opensessionInView这个filter没有配置导致的。

具体原理不明,暂且记下来。

<!-- Hibernate Open Session in View filter --> 
<filter> 
<filter-name>openSessionInViewFilter</filter-name> 
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> 
</filter> 
...... 

<filter-mapping> 
<filter-name>openSessionInViewFilter</filter-name> 
<url-pattern>/*</url-pattern> 
</filter-mapping> 

 

推荐阅读