hibernate exception nested transactions not supported 解决方法

开启事务之前先判断事务是否已经打开,方法如下:
JdbcTransaction tx=(JdbcTransaction) session.beginTransaction(); 
改为JdbcTransaction tx = session.getTransaction().getLocalStatus()==LocalStatus.ACTIVE?(JdbcTransaction)session.getTransaction():(JdbcTransaction) session.beginTransaction(); 
时间: 2024-08-25 00:27:00

hibernate exception nested transactions not supported 解决方法的相关文章

hibernate(nested transactions not supported)异常

org.hibernate.TransactionException: nested transactions not supported错误的解决方法! 原因:事务没有提交,事务提交后正常 Transaction tx = session.beginTransaction(); tx.commit(); //缺少这句话

org.hibernate.TransactionException: nested transactions not supported

贴主要部分代码 public PlUser findByUsernameAndPassword(String username, String password) { Session sx = this.getHibernateTemplate().getSessionFactory().openSession(); Transaction tx = sx.getTransaction(); tx.begin(); PlUser user = (PlUser) sx.createQuery("f

oauth2(spring security)报错method_not_allowed(Request method 'GET' not supported)解决方法

报错信息 <MethodNotAllowed> <error>method_not_allowed</error> <error_description>Request method 'GET' not supported</error_description> </MethodNotAllowed> 39是单引号 原因 默认只支持post 解决方法 下载安装postman工具(或其他post工具) 使用post调用 代码增加get的

关于配置正确hibernate仍然无法创建表的解决方法

 当时全部配置都正确后,而且以前可以正确创建表,为什么突然新写了一个类就不能自动创建了呢.. 其实很简单.. 99%的原因是类的属性名是sql的关键字,不能利用ddl来创建表,还有1%的的原因是没有在cfg中添加 对应的hbm文件.. 嗯  切记... 关于配置正确hibernate仍然无法创建表的解决方法

postman测试接口报Content type &#39;text/plain;charset=UTF-8&#39; not supported解决方法

增加一个请求头管理器,添加content-type:application/json.并将请求修改为json数据传输试试. 参考:https://zhidao.baidu.com/question/1644957725975214740.html postman测试接口报Content type 'text/plain;charset=UTF-8' not supported解决方法 原文地址:https://www.cnblogs.com/xiaoni-fighting/p/12298436.

Minimal BASH-like line editingis supported.解决方法

装了ubuntu系统后在win7下用EasyBCD软件设置引导项,开机选择NeoSmart Linux后出现: Minimal BASH-like line editing is supported.For the first word.TAB lists possible command completions.Anywhere else TAB lists possible device or file completions. grub> 解决方法: ①准备一个Ubuntu自启动U盘(建议

Hibernate配置过程可能发生的问题及解决方法

1.问题:Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException at HibernateTest.main(HibernateTest.java:14) 方法:添加dom4j.jar(解析hibernate.cfg.xml文件) 2.问题:Exception in thread "main" java.lang.NoClassDefFoundErr

Servlet中 End event threw exception,错误404 的解决方法

End event threw exception  SEVERE: End event threw exceptionjava.lang.reflect.InvocationTargetException 这个异常是由于xml配置文件解析错误引起的. 以最近在用ServletContext获取上下文信息时遇到的错误为例: 在web.xml中配置驱动信息: 1 <context-param> 2 <param-name>driver</param-name> 3 <

使用hibernate运行产生的红字解决方法,虽然不影响,但是看着不爽

SLF4J: The requested version 1.6 by your slf4j binding is not compatible with [1.5.5, 1.5.6, 1.5.7, 1.5.8] SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details. log4j:WARN No appenders could be found for logger (org.hiberna