org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not
遇到这个问题之前,我去百度和谷歌去搜索了一下。发现各种说法。可是针对我的项目而言,也就是公司的项目而言,这个问题的根源并不是是网上所说的那样。
最后是通过自己的想法做測试得到了解决。
1.首先说说我的配置吧。我的配置是通过spring自带的注解来实现 声明式事物管理的。假设我们没去了解spring的声明式事物管理的话,也许我们是得不出什么结论的。
假设你配置过声明式事物管理,你就知道spring是怎么帮你管理的。
2.spring声明式事物管理是在service层管理的,关于到sessionFactory.getCurrentSession()的使用时,是具备有tx(Transactional),全部我们必须在service层中进行@Transactional注解,而不能够再dao层或者其它层进行事物的管理。这也是使用注解方式的声明式事物管理的缺点。
3.spring默认的声明式事物管理的是在service层中(注解方式),假设你採用xml方式进行声明式事物管理的话。能够配置你先要声明式事物管理的形态。
org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not的更多相关文章
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not a ...
- spring事务管理出错。No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy ...
- No Hibernate Session bound to thread, and configuration does not allow creat
No Hibernate Session bound to thread, and configuration does not allow creat 今天遇到这么一个错误,在网上差了很多都没有能解 ...
- spring 管理事务配置时,结果 报错: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here这个异常
java.lang.IllegalStateException: No Hibernate Session bound to thread, and configuration does not al ...
- 解决No Hibernate Session bound to thread, and configuration does not allow creat。。。
applicationContext.xml配置 <?xml version="1.0" encoding="UTF-8"?> <beans ...
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not a
如果出现了这个错误,看看在使用Hibernate的时候有没有在事务的环境下执行操作!
- 出现No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here异常
问题描述: public void save(BaseEntity baseEntity) { Session session = null; try { session = currentSessi ...
- 报错解决:No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
大概分析一般使用了注解才会报这方面的错 1.没有在spring的ApplicationContext.xml中开启注解事务 <!-- 开启注解事务 --> <tx:annotatio ...
- No Hibernate Session bound to thread, and configuration does not allow
今天晚上挺悲催的,遇到了这个问题花费我很长时间,现在总结如下: 到这这种情况的发生有两种情况: 1,没有配置事物只要在Spring配置文件中添加如下代码: <bean id="txMa ...
随机推荐
- HTTP的工作原理
客户机与服务器建立连接后,发送一个请求给服务器,请求格式为:统一资源标识符.协议版本号.服务器收到请求的信息(包括请求行,请求头,请求体).服务器接收到请求后,给予相应的响应信息,格式为一个状态行(包 ...
- 【MSSQL】MDF、NDF、LDF文件的含义
[MSSQL]MDF.NDF.LDF文件的含义 2012-09-03 15:32:56| 分类: SQL数据库|举报|字号 订阅 MDF是 primary data file 的缩写:NDF ...
- js文字内容部分选中的代码封装
var textSelect = function(o, a, b){ //o是当前对象,例如文本域对象 //a是起始位置,b是终点位置 var a = parseInt(a, 10), b = pa ...
- mybatis中<![CDATA[]]>的作用
此篇文章引自QH_JAVA的文章 在使用mybatis 时我们sql是写在xml 映射文件中,如果写的sql中有一些特殊的字符的话,在解析xml文件的时候会被转义,但我们不希望他被转义,所以我们要使用 ...
- C语言学习3
实现输入错误后重新输入 通过输入指定的行数和列数打印出二维数组对应的任一行任一列的值: #include <stdio.h> void main() { ][] = {{, , , },{ ...
- 87-Moving average of oscillator,移动平均振荡指标.(2015.7.4)
Moving average of oscillator 移动平均振荡指标 ~计算: OSMA = MACD-SIGNAL 注释:OSMA的值即为MACD中两个主要指标线的差值 ~思想: 该指标当作一 ...
- 笔记——collections模块
collections模块 collections模块在内置数据类型(dict.list.set.tuple)的基础上,还提供了几个额外的数据类型:ChainMap.Counter.deque.def ...
- Floyd算法实现总结
问题描述 给出图,求任意两点的最短距离 算法思路 定义n+1个矩阵矩阵A,和记录路径的矩阵path 依次求A0~An的值,最后的An即为最短路径矩阵 // int A[8][7][7],path[7] ...
- Java AOP
AOP 今天我要和大家分享的是 AOP(Aspect-Oriented Programming)这个东西,名字与 OOP 仅差一个字母,其实它是对 OOP 编程方式的一种补充,并非是取而代之.翻译过来 ...
- [Zabbix] 如何实现邮件报警通知以及免费短信报警通知
版权声明:本文为博主原创文章,未经博主允许不得转载. 前提条件: (1) zabbix服务器端已经成功安装并且运行. (2) zabbix客户端已经成功建立并且运行. 1 下载并且安装msmtp软件 ...