org.hibernate.HibernateException: save is not valid without active transaction at org.hibernate.co
来源:互联网 发布:mac魅可 编辑:程序博客网 时间:2024/05/21 14:40
配置文件为这样
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- 其他配置: 自动建表 显示sql语句 -->
<property name="hibernate.jdbc.use_scrollable_resultset">false</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.show_sql">true</property>
<property name="connection.autocommit">true</property>
////////////////////////////////////////////////////////////////////j加上下面这句就会报错/////////////////////////////////////////////
<property name="hibernate.current_session_context_class">thread</property>
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
<mapping resource="cn/hbmy/tas/entity/User.hbm.xml"></mapping>
<mapping resource="cn/hbmy/tas/entity/Role.hbm.xml"></mapping>
</session-factory>
</hibernate-configuration>
查了一下资料,在单独使用hibernate时,总是会加上这项配置,但spring与hibernate结合时,千万不能加上这句话,我猜测出错原因是事务管理器中的session和当前拿到的session不是同一个session,事务管理器中拿到的session开启了事务,但当前得到的session并没有开启事务,导致出错。所以在整合框架的时候,就不要加上这句话了!!!
阅读全文
1 0
- org.hibernate.HibernateException: save is not valid without active transaction at org.hibernate.co
- org.hibernate.HibernateException: save is not valid without active transaction
- org.hibernate.HibernateException: save is not valid without active transaction
- org.hibernate.HibernateException: createSQLQuery is not valid without active transaction
- org.hibernate.HibernateException: delete is not valid without active transaction
- org.hibernate.HibernateException: createSQLQuery is not valid without active transaction
- spring 管理 hibernate 事物,抛异常 org.hibernate.HibernateException: save is not valid without active transa
- Exception in thread "main" org.hibernate.HibernateException: save is not valid without active transa
- ssh整合报错org.hibernate.HibernateException: createQuery is not valid without active transaction
- 使用S2SH框架时,出现org.hibernate.HibernateException: createQuery is not valid without active transaction
- SSH 整合报org.hibernate.HibernateException: ...... is not valid without active transaction异常
- Hibernate 配置使用线程报错org.hibernate.HibernateException: createCriteria is not valid without active trans
- Exception in thread "main" org.hibernate.HibernateException: get is not valid without active transac
- spring声明式管理事务+ hibernate + save is not valid without active transaction
- spring+hibernate进行线程操作时异常:save is not valid without active transaction
- hibernate中: is not valid without active transaction
- hibernate错误:load is not valid without active transaction
- Hibernate SessionFactory getCurrentSession is not valid without active transaction
- 系统吞吐量(TPS)、用户并发量、性能测试概念和公式
- Open-Sourcing LayoutKit
- 隐藏算法的性能指标
- java集合
- malloc和new的区别
- org.hibernate.HibernateException: save is not valid without active transaction at org.hibernate.co
- Tesseract在Android上的使用
- angular学习网站
- wcf返回datatable必须给tablename赋值
- Location-Aware-Instant:开发即时位置感知的Android客户端
- 搜索引擎选择: Elasticsearch与Solr
- google vr 入门之VrPanoramaView制作全景图列表
- Eclipse开发SpringMVC简单小程序
- 业界良心? 谷歌宣布Chrome将自带广告拦截功能