spring整合hibernate的时候报异常org.hibernate.HibernateException: createQuery is not valid without active transaction
在整合Spring4+hibernate4时候,当代码执行到dao中CRUD操作时,报了一个异常,
org.hibernate.HibernateException: createQuery is not valid without active transaction ...
因为我用到的是session是通过sessionFactory.getCurrentSession()方法获得到的,这个session是和事务(transaction)绑定的,这个异常是告诉我,session的操作没有在一个活动的事务下进行,可是我检查了spring配置文件,是没有错误的,,试了很多种解决方法都没有成功,最后发现了问题,把hibernate.cfg.xml:中的一句代码:hibernate.current_session_context_class删掉之后,就能正常运行了.
详细原因的分析,这篇博文写的不错.http://blog.csdn.net/yinjian520/article/details/8666695
spring整合hibernate的时候报异常org.hibernate.HibernateException: createQuery is not valid without active transaction的更多相关文章
- Exceprtion:e createQuery is not valid without active transaction; nested exception is org.hibernate.HibernateException: createQuery is not valid without active transaction
如果增加配置了current_session_context_class属性,查询的时候需要session.beginTrasaction()来开启事务
- spring中使用Hibernate中的getCurrentSession报出:createQuery is not valid without active transaction
1.错误信息 HTTP Status 500 - createQuery is not valid without active transaction type Exception report m ...
- Exception in thread "main" org.hibernate.HibernateException: save is not valid without active transaction
在spring4+hibernate4整合过程中,使用@Transactional注解事务会报"Exception in thread "main" org.hibern ...
- org.hibernate.HibernateException: getFlushMode is not valid without active transaction
Spring & Hibernate 整合异常记录: org.hibernate.HibernateException: getFlushMode is not valid without a ...
- Hibernate 与Spring整合出现 hibernate.HibernateException: createCriteria is not valid without active transaction
当 Hibernate 和 Spring 整合时,在 Spring 中指定的 Hibernate.cfg.xml 文件内容中要注释掉以下内容: <!-- Enable Hibernate's a ...
- 异常:getHibernateFlushMode is not valid without active transaction; nested exception is org.hibernate.HibernateException: getHibernateFlushMode is not valid without active transaction getHibernateFlu
场景: 在使用spring整合hibernate调用的HibernateTemplate时报错解决: 在spring配置文件中添加事务的配置 <bean id="hibernateTr ...
- 编程异常——假设你报createSQLQuery is not valid without active transaction,...
非常多时候我们使用hibernate的session时,都是让session在某一执行环境中保持其唯一. 比如在同一线程内用同一个session.在同一方法内用同一session,这样我们就能够用se ...
- spring整合web的ssh(springMVC、hibernate)
1. tomcat启动时,加载配置文件,将bean装在 导入jar包spring-web..jar 2.确定配置文件位置 3.spring整合hibernate <!-- 加载hibernate ...
- Hibernate和Spring整合出现懒加载异常:org.hibernate.LazyInitializationException: could not initialize proxy - no Session
出现问题: SSH整合项目里,项目目录结构如下: 在EmployeeAction.java的list()方法里将employees的list放入到request的Map中. EmployeeActi ...
随机推荐
- SQL执行效率1
第一种方法:使用insert into 插入,代码如下: ? 1 2 3 4 5 6 7 $params = array('value'=>'50′); set_time_limit(0); e ...
- input框focus时的美化效果
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- web端限时活动逻辑处理总结
由于要在web端做一个限时活动的功能,功能大致为:一个小时内可以报名参加活动,然后给予报名者奖品,先到先得.用到一些处理逻辑做下总结,以前没有做过类似的东西,都是自己先体验其他网站的报名方式,然后再摸 ...
- 10年微软MVP路(如何成为一个MVP?)
搞微软技术的,大家或多或少都有听说过微软的"最有价值专家"(MVP), 从2006年到2015年连续10年ASP.NET/IIS MVP.当年很多一起搞微软技术的朋友都转搞其他非微 ...
- 【腾讯Bugly干货分享】美团大众点评 Hybrid 化建设
本文来自于腾讯Bugly公众号(weixinBugly),未经作者同意,请勿转载,原文地址:http://mp.weixin.qq.com/s/rNGD6SotKoO8frmxIU8-xw 本期 T ...
- 剑指Offer面试题:9.二进制中1的个数
一.题目:二进制中1的个数 题目:请实现一个函数,输入一个整数,输出该数二进制表示中1的个数.例如把9表示成二进制是1001,有2位是1.因此如果输入9,该函数输出2. 二.可能引起死循环的解法 一个 ...
- 纯命令行的编辑利器:用好 awk 与 sed
awk 的基本语法 awk 是模式查找与处理语言,是文本处理的利器.使用 awk 可以只用一条简单的命令完成复杂的文本数据处理. awk 命令的基本结构为: awk '模式 {处理}' 文件 比如,打 ...
- 关于分工的思考 (Thoughts on Division of Labor)
Did you ever have the feeling that adding people doesn't help in software development? Did you ever ...
- Java static 的一两点使用
这篇文章是关于Java static关键字的使用,主要会介绍以下的内容: static 的概念 static的各种应用 总结 static 是什么 static 顾名思义是静态的意思.与this相对, ...
- ESP8266刷AT固件与nodemcu固件
这回是使用的这一款 因为这款默认的是支持AT指令的固件,,所以我们就刷nodemcu的 先看接线 GPIO0 默认是工作模式(不接线).如果接了低电平就是下载模式(给模块刷固件!!)所以接低电平.CH ...