Could not obtain transaction-synchronized Session for current thread原因及解决方案
问题
用sessionFactory.getCurrentSession()
这样获取session,抛了这异常。
解决
- 必须要将使用了
sessionFactory.getCurrentSession()
获取session的代码所在的方法加入到事务管理器
中;否则获取不到session了。 sessionFactory.getCurrentSession()
是要基于事务
的,才能实现session生命周期的管理。所以查询方法上用只读事务就ok了。
参考:
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 hibernate4和5不支持你用hibernate3的 ge ...
- 错误记录(九)Could not obtain transaction-synchronized Session for current thread
报错信息: org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for curren ...
- 浪涌电流Inrush Current产生原因以及解决方案
一.Inrush Current涌浪电流产生原因 1.对Inrush Current电流的直观感受 当电灯在电路中工作时,如果突然启动马达或者变压器时,会出现电灯暗一下,此时电灯出现暗的情况就是因为马 ...
- 阿了嗝欢的小白日记——No session异常的发生原因和解决方案
今天被朋友问到No Session异常,虽然很困想睡会午觉,不过为了能保持写博客的好习惯,这会儿就拿休息时间来写一篇关于No session的文章. No Session异常是一种经典的异常!为什么这 ...
- org.hibernate.HibernateException: No Session found for current thread
spring.springmvc和hibernate整合 在sessionFactory.getCurrentSession()时,出现以下异常 No Session found for curren ...
- SpringMVC @Transactional的陷井大坑引发No Session found for current thread
一.TransactionManager事务配置 (1)注解配置 配置spring的xml加@Transactional <tx:annotation-driven transaction-ma ...
- jpa 报错:No EntityManager with actual transaction available for current thread - cannot reliably proce
No EntityManager with actual transaction available for current thread - cannot reliably process 'rem ...
- 解决No EntityManager with actual transaction available for current thread
问题描述: 在使用JPA执行删除操作时报错: No EntityManager with actual transaction available for current thread - canno ...
- No EntityManager with actual transaction available for current thread - cannot reliably process ‘rem
[spring data jpa]使用spring data jpa 的删除操作,需要加注解@Modifying @Transactional 否则报错如下: No EntityManager wit ...
最新文章
- Android 屏幕适配从未如斯简单(8月10日最终更新版)
- 用AsyncCtp实现一个简单的EchoServer
- windows 禁用ipv6服务_Win10如何关闭IPV6?Win10禁用IPv6的方法
- 使用Xftp5连接云服务器
- ArcGIS Engine开发之旅08--和查询相关的对象和接口
- 自动化审批决策树助你面试更上一层楼
- ArcGIS API for JavaScript心得体验
- Okhttp之RouteSelector简单解析
- python问卷星微信登录_Python+Selenium自动刷问卷星问卷
- 儿童节html5小游戏,2016六一儿童节主题班会小游戏大全
- lighttpd出现mod_indexfile.so: cannot open shared object file: No such file or directory
- [RK3399][Android7.1] 移植笔记 --- 9.7寸eDP显示屏添加
- Bryntum Gantt 5.2.2 New-Crack
- 物流系统管理课程(二十五)
- 场景文字识别论文阅读
- stm32mp157开发板MIC 接口测试方法
- 我国计算机通信技术现状及未来的发展趋势,概述计算机通信技术的发展趋势
- JOL工具及其分析对象在JVM的大小和分布
- linux centos7 镜像下载
- 推荐算法评测方法总结
热门文章
- 试除法计算最小的N个素数
- matlab 格式化文本文件的解析
- Exception in thread “main” java.lang.NoClassDefFoundError: com/google/common/base/Preconditions
- C 标准库 —— limits.h
- python自动化办公-python自动化办公?学这些就够用了
- python怎么读取excel-python对Excel的读取
- 一张图学会python高清图-一张图让你学会Python
- python是什么软件-Python 是什么软件?
- python零基础能学吗-python 零基础该怎么学?
- 长虹新一代人工智能电视Q6A、Q6K发布,搭载远场语音识别