问题

sessionFactory.getCurrentSession()这样获取session,抛了这异常。

解决

  1. 必须要将使用了sessionFactory.getCurrentSession()获取session的代码所在的方法加入到事务管理器中;否则获取不到session了。
  2. sessionFactory.getCurrentSession()是要基于事务的,才能实现session生命周期的管理。所以查询方法上用只读事务就ok了。

参考:

Could not obtain transaction-synchronized Session for current thread原因及解决方案相关推荐

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

    Could not obtain transaction-synchronized Session for current thread hibernate4和5不支持你用hibernate3的 ge ...

  2. 错误记录(九)Could not obtain transaction-synchronized Session for current thread

    报错信息: org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for curren ...

  3. 浪涌电流Inrush Current产生原因以及解决方案

    一.Inrush Current涌浪电流产生原因 1.对Inrush Current电流的直观感受 当电灯在电路中工作时,如果突然启动马达或者变压器时,会出现电灯暗一下,此时电灯出现暗的情况就是因为马 ...

  4. 阿了嗝欢的小白日记——No session异常的发生原因和解决方案

    今天被朋友问到No Session异常,虽然很困想睡会午觉,不过为了能保持写博客的好习惯,这会儿就拿休息时间来写一篇关于No session的文章. No Session异常是一种经典的异常!为什么这 ...

  5. org.hibernate.HibernateException: No Session found for current thread

    spring.springmvc和hibernate整合 在sessionFactory.getCurrentSession()时,出现以下异常 No Session found for curren ...

  6. SpringMVC @Transactional的陷井大坑引发No Session found for current thread

    一.TransactionManager事务配置 (1)注解配置 配置spring的xml加@Transactional <tx:annotation-driven transaction-ma ...

  7. 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 ...

  8. 解决No EntityManager with actual transaction available for current thread

    问题描述: 在使用JPA执行删除操作时报错: No EntityManager with actual transaction available for current thread - canno ...

  9. No EntityManager with actual transaction available for current thread - cannot reliably process ‘rem

    [spring data jpa]使用spring data jpa 的删除操作,需要加注解@Modifying @Transactional 否则报错如下: No EntityManager wit ...

最新文章

  1. Android 屏幕适配从未如斯简单(8月10日最终更新版)
  2. 用AsyncCtp实现一个简单的EchoServer
  3. windows 禁用ipv6服务_Win10如何关闭IPV6?Win10禁用IPv6的方法
  4. 使用Xftp5连接云服务器
  5. ArcGIS Engine开发之旅08--和查询相关的对象和接口
  6. 自动化审批决策树助你面试更上一层楼
  7. ArcGIS API for JavaScript心得体验
  8. Okhttp之RouteSelector简单解析
  9. python问卷星微信登录_Python+Selenium自动刷问卷星问卷
  10. 儿童节html5小游戏,2016六一儿童节主题班会小游戏大全
  11. lighttpd出现mod_indexfile.so: cannot open shared object file: No such file or directory
  12. [RK3399][Android7.1] 移植笔记 --- 9.7寸eDP显示屏添加
  13. Bryntum Gantt 5.2.2 New-Crack
  14. 物流系统管理课程(二十五)
  15. 场景文字识别论文阅读
  16. stm32mp157开发板MIC 接口测试方法
  17. 我国计算机通信技术现状及未来的发展趋势,概述计算机通信技术的发展趋势
  18. JOL工具及其分析对象在JVM的大小和分布
  19. linux centos7 镜像下载
  20. 推荐算法评测方法总结

热门文章

  1. 试除法计算最小的N个素数
  2. matlab 格式化文本文件的解析
  3. Exception in thread “main” java.lang.NoClassDefFoundError: com/google/common/base/Preconditions
  4. C 标准库 —— limits.h
  5. python自动化办公-python自动化办公?学这些就够用了
  6. python怎么读取excel-python对Excel的读取
  7. 一张图学会python高清图-一张图让你学会Python
  8. python是什么软件-Python 是什么软件?
  9. python零基础能学吗-python 零基础该怎么学?
  10. 长虹新一代人工智能电视Q6A、Q6K发布,搭载远场语音识别