can begin transaction in hibernate called while commiting/rollback
来源:互联网 发布:js获取跳转前的url 编辑:程序博客网 时间:2024/05/29 17:26
Will the below code works fine or do I need to begin transaction before doing work.
Session session = SessionFactory.openSession();//do some work like session.save/Updatefinally{ session.beginTransaction().commit();}
No. Of course the code being part of the transaction must be between the begin and the commit of the transaction.
Here(s what the documentation says:
The session/transaction handling idiom looks like this:
// Non-managed environment idiomSession sess = factory.openSession();Transaction tx = null;try { tx = sess.beginTransaction(); // do some work ... tx.commit();}catch (RuntimeException e) { if (tx != null) tx.rollback(); throw e; // or display error message}finally { sess.close();}
No you need to manage transaction, commit for getting immediate effect and any exceptions thrown by Hibernate are FATAL, you have to roll back the transaction and close the current session.
0 0
- can begin transaction in hibernate called while commiting/rollback
- begin transaction/rollback transaction
- Error while commiting the transaction
- nested exception is javax.persistence.RollbackException: Error while commiting the transaction
- What will happen if we begin transaction in hibernate but do not commit it?
- rollback transaction
- [Microsoft][SQLServer JDBC Driver]Can't start a cloned connection while in manual transaction mode
- Can't start a cloned connection while in manual transaction mode
- sql server 出现Can't start a cloned connection while in manual transaction mode 的解决方法
- Can't start a cloned connection while in manual transaction mode的解决方法
- jsp Can't start a cloned connection while in manual transaction mode解决
- Can't start a cloned connection while in manual transaction mode.
- Can't start a cloned connection while in manual transaction mode.解决方法
- Can't start a cloned connection while in manual transaction mode.错误的解决方案
- Can't start a cloned connection while in manual transaction mode
- Sql Server2000 Can't start a cloned connection while in manual transaction mode
- Can't start a cloned connection while in manual transaction mode
- Can't start a cloned connection while in manual transaction mode 解决
- Div+CSS布局之写入整体层结构与CSS
- [总结]视音频编解码技术零基础学习方法
- ubuntu recovery mode root readonly filesystem 解决
- Tomcat启动读取applicationContext.xml出错的解决方式
- python中令人蛋疼的地方及一些技巧
- can begin transaction in hibernate called while commiting/rollback
- 《JAVA NIO》读书笔记+java.nio源码解析
- hdu 5442 Favorite Donut(后缀数组)
- JSP内置对象1
- CSS实现省略号
- php 显示中文乱码问题分析
- 《C和指针》读书笔记--标准输入输出函数和基础的字符串操纵函数
- OSI七层模型详解
- cookie定义与应用