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 ...
随机推荐
- Python之路第一课Day7--随堂笔记(面向对象编程进阶...未完待续 )
本节内容: 面向对象高级语法部分 静态方法.类方法.属性方法 类的特殊方法 反射 异常处理 Socket开发基础 作业:开发一个支持多用户在线的FTP程序 面向对象高级语法部分 一.静态方法 通过@s ...
- android 通过uri获取bitmap图片并压缩
很多人在调用图库选择图片时会在onActivityResult中用Media.getBitmap来获取返回的图片,如下: Uri mImageCaptureUri = data.getData(); ...
- centos 7.2 安装PHP7.1+apache2.4.23
安装准备: http://ftp.cuhk.edu.hk/pub/packages/apache.org//httpd/httpd-2.4.23.tar.gz 下载apache http://cn ...
- JS中的柯里化与反柯里化
先占个位 看了一天折资料,感觉清楚多了
- 关于pl/sql数据库下拉中选项为空的问题
1.可能是在配置环境变量TNS_ADMIN的时候后面多了一个分号,去掉分号就可以了
- jQuery模仿淘宝商品评价
最近做项目要做个商品评价的功能,我直接就跑到淘宝那里去研究了,可看着晕晕的,还不知道他是怎么做的,于是把图抠了下来,自己写了一个,接下来就展示一下我是怎么做的,大家有不同的实现方法可要记得分享一下呀. ...
- Collections+Iterator 接口 | Map+HashMap+HashTable+TreeMap |
Collections+Iterator 接口 1. Collections 是一个操作 Set.List 和 Map 等集合的工具类 Collections 中提供了大量方法对集合元素进行排序.查询 ...
- 开发必备的Windows小技巧
在Windows中我们经常会遇到各种小问题,而这些小问题又确实在影响着工作效率,如果能解决这些小问题,那么就能在一定程度上提高工作效率,保证心情愉悦.今天我就来分享一下几个自认为比较有用的小技巧. 保 ...
- 谷歌chrome浏览器www.tradeadexchange.com广告弹窗跳转劫持病毒
近期大量网友出现chrome浏览器被劫持的情况,表现如下: · 点击(访问)任意网站任意链接均有概率弹出www.tradeadexchange.com. · ...
- 我所记录的git命令(非常实用)
一.前言 记录一下工作中常用到的git命令,只是简单的笔记,欢迎大家交流... [ 顺便问下园友们,怎么感觉博客园发布的博客搜索有时都搜不到,后台编辑能填的都填写了,还是觉得搜索排名不高? 相同的标题 ...