save is not valid without active transaction
org.hibernate.HibernateException: save is not valid without active transaction
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:340)
at com.sun.proxy.$Proxy4.save(Unknown Source)
at liuyang.dao.DeptDao_a.save(DeptDao_a.java:15)
at liuyang.service.DeptService_a.serviceSave(DeptService_a.java:15)
at test.TestHibernate.test(TestHibernate.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
这个错误是在hbiernate.cfg.xml中加载了线程控制
<prop key="hibernate.current_session_context_class">thread</prop>
把这句删除错误就消失了.版本3不用加载这个.
save is not valid without active transaction的更多相关文章
- Exception in thread "main" org.hibernate.HibernateException: save is not valid without active transaction
在spring4+hibernate4整合过程中,使用@Transactional注解事务会报"Exception in thread "main" org.hibern ...
- 编程异常——假设你报createSQLQuery is not valid without active transaction,...
非常多时候我们使用hibernate的session时,都是让session在某一执行环境中保持其唯一. 比如在同一线程内用同一个session.在同一方法内用同一session,这样我们就能够用se ...
- 如果你报createSQLQuery is not valid without active transaction,请看这里
原文:https://blog.csdn.net/yinjian520/article/details/8666695 很多时候我们使用hibernate的session时,都是让session在某一 ...
- spring整合hibernate的时候报异常org.hibernate.HibernateException: createQuery is not valid without active transaction
在整合Spring4+hibernate4时候,当代码执行到dao中CRUD操作时,报了一个异常, org.hibernate.HibernateException: createQuery is n ...
- 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 ...
- org.hibernate.HibernateException: getFlushMode is not valid without active transaction
Spring & Hibernate 整合异常记录: org.hibernate.HibernateException: getFlushMode is not valid without 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 ...
- Hibernate 与Spring整合出现 hibernate.HibernateException: createCriteria is not valid without active transaction
当 Hibernate 和 Spring 整合时,在 Spring 中指定的 Hibernate.cfg.xml 文件内容中要注释掉以下内容: <!-- Enable Hibernate's a ...
- 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()来开启事务
随机推荐
- Android软键盘弹出将底部栏顶上去并不会挤压界面
界面需要,找到了一种不需要去设置android:windowSoftInputMode属性的解决keyboard和layout不适问题 有关设置android:windowSoftInputMode的 ...
- UE4 代码总结
1.创建关卡类 1.创建C++类继承LevelScriptActor 2.打开关卡蓝图 Class Settings->Parent Class 选择你之前创建好的C++类 遇到的问题: 1.T ...
- 【UVA】10763 Foreign Exchange(map)
题目 题目 分析 没什么好说的,字符串拼接一下再放进map.其实可以直接开俩数组排序后对比一下,但是我还是想熟悉熟悉map用法. 呃400ms,有点慢. 代码 #include < ...
- 快速安装laravel和依赖
http://pkg.phpcomposer.com CMD敲命令: composer config -g repositories.packagist composer http://packagi ...
- 14_java之变量|参数|返回值|修饰符
01java中的文档注释和制作 * A: 在eclipse使用时,可以配合文档注释,导出对类的说明文档,从而供其 他人阅读学习与使用. 通过使用文档注释,将类或者方法进行注释用@简单标注基本信息.如@ ...
- Android 4 学习(18):搜索
参考<Professional Android 4 Development> 搜索 通过下面这几种方式可以给应用程序添加搜索功能: Search Bar Search View Quick ...
- 检测客户端系统-PHP
if(isset($_SERVER['HTTP_USER_AGENT'])) { $userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); $clie ...
- GPRS 通信
最近使用SIM900A GSM/GPRS模块,做一些简单物联网信息投递. 1.选取何种流量卡 一般来讲,需要带身份证去运营商办理新的电话卡.对于小流量用户,实际上就是办一个最低月租即可,因为套餐会赠送 ...
- 解决办法 Field userService in com.sxsj.controller.RegistLoginController required a bean of type
转自:https://blog.csdn.net/awmw74520/article/details/82687288 APPLICATION FAILED TO START Error starti ...
- UGUI 学习
1. Grid Layout Group(网格布局) Hierachy: Game: 属性和功能: 2. 根据鼠标位置旋转界面实现: public class TiltWindow : MonoBeh ...