spring 管理 hibernate 事物,抛异常 org.hibernate.HibernateException: save is not valid without active transa
来源:互联网 发布:淘宝前十女装店 编辑:程序博客网 时间:2024/05/21 09:57
在使用spring 管理hibernate事物时
spring 中配置:
<!-- 配置申明式的事务管理(基于注解)事务加在父类上 子类也有事务 所以事务一般加载 baseservice 上 -->
<bean id= "transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager" >
<property name="sessionFactory" ref="sessionFactory" ></property>
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
但是在测试时 抛出异常:
org.hibernate.HibernateException: save is not valid without active transaction
该异常表示 hibernate 没有拿到事务。
查看hibernate.cfg.xml 中配置:
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
current_session_context_class 表示当前 在调用getcurrentSession 方法是 是冲那里获取事务
表示重线程中获取事务。
百度后 了解 此处配置有问题应该为:
< property name ="current_session_context_class">org.springframework.orm.hibernate4.SpringSessionContext </property>
表示 spring 为 当前session 提供事务。
- 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
- org.hibernate.HibernateException: save is not valid without active transaction
- org.hibernate.HibernateException: save is not valid without active transaction
- org.hibernate.HibernateException: save is not valid without active transaction at org.hibernate.co
- 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
- SSH 整合报org.hibernate.HibernateException: ...... is not valid without active transaction异常
- spring+hibernate进行线程操作时异常:save is not valid without active transaction
- Hibernate 配置使用线程报错org.hibernate.HibernateException: createCriteria is not valid without active trans
- spring声明式管理事务+ hibernate + save is not valid without active transaction
- ssh整合报错org.hibernate.HibernateException: createQuery is not valid without active transaction
- 使用S2SH框架时,出现org.hibernate.HibernateException: createQuery is not valid without active transaction
- Exception in thread "main" org.hibernate.HibernateException: get is not valid without active transac
- Spring 整合 hibernate 时,抛异常: createQuery is not valid without active transaction
- spring和hibernate整合时异常(详解): getFlushMode is not valid without active transaction
- spring和hibernate整合时异常(详解): getFlushMode is not valid without active transaction
- EMV技术学习和研究(五)脱机数据认证之DDA
- 解决eclipse ADT编译NDK报NDK和minSdkVersion不匹配的问题
- windows KdPrint打印中文文件夹的问题,应该是DbgPrint的BUG
- org.apache.shiro.UnavailableSecurityManagerException: No SecurityManager accessible to the calling c
- 磨刀不误砍柴功:App开发者必备的运营、原型、UI设计工具整理
- spring 管理 hibernate 事物,抛异常 org.hibernate.HibernateException: save is not valid without active transa
- 2013年7月7日 23:49:22
- shell检查服务是否启动
- Android 更新UI的两个方法
- Java类之间的关联关系
- GNU GPL
- WCF学习资料
- ipad与iphone区别之一
- Discuz X2.5 用户名包含被系统屏蔽的字符[解决方法]