Could not obtain transaction-synchronized Session for current thread
来源:互联网 发布:高晓松酒驾 知乎 编辑:程序博客网 时间:2024/05/17 04:42
spring4. 3 + hibernate4.3 执行sessionFactory.getCurrentSession() 抛 Could not obtain transaction-synchronized Session for current thread 异常。
解决方法:添加
<filter><filter-name>openSessionInView</filter-name><filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class></filter><filter-mapping><filter-name>openSessionInView</filter-name><url-pattern>/*</url-pattern></filter-mapping>
OpenSessionInViewFilter的主要功能是用来把一个Hibernate Session和一次完整的请求过程对应的线程相绑定。Open Session In View在request把session绑定到当前thread期间一直保持hibernate session在open状态,使session在request的整个期间都可以使用。
阅读全文
0 0
- 【Hibernate】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
- Could not obtain transaction-synchronized Session for current thread
- HibernateException: 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
- 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
- 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
- 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
- Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- bitTiger讲解:Leetcode如何刷(经验分享)
- [机器学习实战] Ubuntu 16.04 + NVIDIA 384 + OpenCV 3.1.0 + CUDA 8.0 + cuDNN 5.1 踩坑记录
- Prim和Kruskal求最小生成树
- 递归算法的时间复杂度分析
- 344. Reverse String
- Could not obtain transaction-synchronized Session for current thread
- codevs 2604 舞会邀请 tarjan
- SpringMVC重要接口(二)HandlerMethodReturnValueHandler
- 使用OpenCV进行目标检测的注意事项
- 0基础lua学习(十一)table
- (递归)逆波兰表达式
- Python字典集合数据结构深入理解
- object
- LitePal使用UUID作为主键