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 ...
随机推荐
- flutter 异步async、await和Future的使用技巧
由于前面的HTTP请求用到了异步操作,不少小伙伴都被这个问题折了下腰,今天总结分享下实战成果.Dart是一个单线程的语言,遇到有延迟的运算(比如IO操作.延时执行)时,线程中按顺序执行的运算就会阻塞, ...
- Fiddler抓包使用教程-扫盲篇
转载请标明出处:http://blog.csdn.net/zhaoyanjun6/article/details/72823370 本文出自[赵彦军的博客] 1.什么是抓包? 不同主机之间的数据通信都 ...
- python 中* 和**的作用
先举个 ** 使用的例子: data = {"a": 1, "b": 2} def foo(**kwargs): print kwargs foo(a=1, b ...
- Python之聚类(KMeans,KMeans++)
# -*- coding: utf-8 -*- """ Created on Mon Sep 17 16:41:46 2018 @author: zhen "& ...
- leveldb源码分析--SSTable之block
在SSTable中主要存储数据的地方是data block,block_builder就是这个专门进行block的组织的地方,我们来详细看看其中的内容,其主要有Add,Finish和CurrentSi ...
- Jboss7.1 local EJB lookup problem
We are trying to lookup for an Local EJB in JBoss7.1, but we get an ClassCast Exception. This local ...
- 关于MSCOMM.OCX无法正常注册的问题解决
[问题] 关于“Component'MSCOMM32.OCX'or one of its dependencies not correctly registered: afole is missing ...
- sql server数据导入导出方法统计
常用的数据量不是很大的情况的几种方法:转载地址 http://www.cnblogs.com/changbluesky/archive/2010/06/23/1761779.html 大数据量的推荐导 ...
- chattr -lsattr 文件加锁解锁简单用法
chattr: 加锁文件,无修改,无删除权限. 常用参数: +a: 可给文件追加内容,但无法删除. +i 加锁文件(文件不能被删除.改名.设定链接关系,同时不能写入或追加内容) -i ...
- Python初学者第三天 运算符、while循环
3day Python基础语法 1.运算符:算数运算符.比较运算符.赋值运算符.逻辑运算符 A.算数运算符:a=10,b=3 + 加 a+b - 减 a-b * 乘 a*b / 除 a/b ...