Could not obtain transaction-synchronized Session for current thread
Posted doudou-123
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Could not obtain transaction-synchronized Session for current thread相关的知识,希望对你有一定的参考价值。
配置session有误:在项目中一般都是自动打开session和关闭session,需要在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>
这里的singleSession的默认值为true,也就是自动打开和关闭session
以上是关于Could not obtain transaction-synchronized Session for current thread的主要内容,如果未能解决你的问题,请参考以下文章
Could not obtain transaction-synchronized Session for current thread
Could not obtain transaction-synchronized Session for current thread
org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thre
Could not obtain transaction-synchronized Session for current thread
Could not obtain connection metadata
Could not obtain connection to query metadata : Public Key Retrieval is not allowed