Could not obtain transaction-synchronized Session for current thread原因及解决方案
一、问题的产生

二、问题的解决过程
(1)先看下Hibernate相关的配置

(2)从网上找答案

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


三、小结
Could not obtain transaction-synchronized Session for current thread原因及解决方案的更多相关文章
- 记一次bug思考过程:HibernateException: Could not obtain transaction-synchronized Session for current thread
场景:把从客户端提交的任务放到线程池执行 异常:HibernateException: Could not obtain transaction-synchronized Session for cu ...
- Hibernate4中使用getCurrentSession报Could not obtain transaction-synchronized Session for current thread
架个spring4+hibernate4的demo,dao层直接注入的sessionFactory,然后用getCurrentSession方法获取session,然后问题来了,直接报错: Could ...
- 关于Hibernate Could not obtain transaction-synchronized Session for current thread
转载自 http://blog.csdn.net/flyjiangs/article/details/51537381 最近几年一直再搞android,最近闲下来了,顺便玩一下web. 整了个最新版本 ...
- 关于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 thread
spring与hibernate整合报错 org.hibernate.HibernateException: Could not obtain transaction-synchronized Ses ...
- Hibernate Could not obtain transaction-synchronized Session for current thread问题处理
项目通过Hibernate查询时报出如下错误: Hibernate Could not obtain transaction-synchronized Session for current thre ...
- Hibernate4 No Session found for current thread原因
Hibernate4 与 spring3 集成之后, 如果在取得session 的地方使用了getCurrentSession, 可能会报一个错:“No Session found for curre ...
- SSH2 No Session found for current thread原因
Hibernate4 与 spring3 集成之后, 如果在取得session 的地方使用了getCurrentSession, 可能会报一个错:“No Session found for curre ...
- Could not obtain transaction-synchronized Session for current thread 错误的解决方法!
BsTable bsTable = new BsTable(); // String time = request.getParameter("date"); String tim ...
随机推荐
- Android中使用Log4j及配置说明
目前在进行Android开发时使用到了log4j,现在对其配置进行记录. 1. android-logging-log4j 下载地址 https://code.google.com/archive/p ...
- 通过 Cobalt Strike 利用 ms14-068
拓扑图 攻击者(kali) 位于 192.168.245.0/24 网段,域环境位于 192.168.31.0/24 网段. 域中有一台 win7 有两张网卡,可以同时访问两个网段,以这台机器作为跳板 ...
- Android Studio离线打包5+SDK
dcloud官网下载最新版5+SDK 解压后,Android Studio导入HBuilder-Hello,选择From eclispe 修改assets/data/dcloud_control.xm ...
- Express浅谈
写给鸟自己的,大家如果不慎百度到这里来了,真好也在做这块功能,不懂的可以联系鸟.微信:jkxx123321 const Sequelize = require('sequelize'); const ...
- MySQL——索引基础
本篇文章,我们将从索引基础开始,介绍什么是索引以及索引的几种类型,然后学习如何创建索引以及索引设计的基本原则. 本篇文章中用于测试索引创建的user表的结构如下: 什么是索引 索引(在 MySQL 中 ...
- 犀牛Rhino教程合集37部
犀牛Rhino教程合集37部 教程说明:英文视频教程,部分有中文字幕,大部分有工程文件 教程格式:Flv.MP4格式,大部分高清,确保能看清软件上的文字 发货方式:百度网盘下载链接(教程较多,可转存到 ...
- EFCore中SQLSERVER 2008 的分页问题
自SQLSERVER 2012起新增了 Offset Fetch 语法,因此EFCore默认是以此语法生成相应的分页语句的. 如果我们的目标数据库低于 2012,那么EFCore默认生成的语句在执行的 ...
- 使用MonkeyTest对Android客户端进行压力测试
目录 monkey命令简介 monkey命令参数说明 自动化实例 如何通过日志定位问题 1.monkey命令简介 Monkey是Android中的一个命令行工具,可以运行在模拟器里或实际设备中.它 ...
- jmeter之数据库相关
一.JDBC Connection Configuration 1.Variable Name Bound to Pool-Variable Name:连接池名称, JDBC Request通过此名称 ...
- 关于npm run build打包后css样式中的图片失效的问题(如background)
平时run dev都能正常显示的css背景图片在npm run build打包后竟然不显示了(写在标签对中的图片都可以正常显示),而且dist/static/img目录下是确实有这张图片的,于是查看打 ...