Transaction not successfully started 处理办法
来源:互联网 发布:linux 添加path 编辑:程序博客网 时间:2024/06/04 19:04
package com.demo.hibernate.dao;import org.hibernate.HibernateException;import org.hibernate.Query;import org.hibernate.Session;import org.hibernate.Transaction;import com.demo.hibernate.beans.User;import com.demo.hibernate.util.HibernateSessionFactory;public class UserDAO {public User getUser(String username) throws HibernateException{Session session = null;Transaction tx = null;User user = null;try{session = HibernateSessionFactory.currentSession();tx = session.beginTransaction();Query query = session.createQuery("from User where username=?");query.setString(0, username.trim());user = (User)query.uniqueResult();query = null;tx.commit();}catch(HibernateException e){if(tx!=null){tx.rollback();}throw e;}finally{HibernateSessionFactory.closeSession();}return user;}}
控制台出现报错
Exception in thread "main" org.hibernate.TransactionException: Transaction not successfully started
解决方法:
catch (HibernateException e) {
文章来源:http://blog.sina.com.cn/s/blog_67c92e8d0100izhc.html
参考:http://blog.csdn.net/mfhappy/article/details/7428924
- Transaction not successfully started 处理办法
- 有关Transaction not successfully started问题解决办法
- Transaction not successfully started
- Transaction not successfully started
- Transaction not successfully started
- ansaction not successfully started 处理办法
- Transaction not successfully started 异常的解决
- org.hibernate.TransactionException: Transaction not successfully started
- org.hibernate.TransactionException: Transaction not successfully started
- 出现org.hibernate.TransactionException: Transaction not successfully started的原因
- hibernate提示错误的原因Transaction not successfully started
- Hibernate 错误解决(TransactionException: Transaction not successfully started)
- 出现org.hibernate.TransactionException: Transaction not successfully started
- spring管理hibernate事务报异常--Transaction not successfully started解决方法
- spring管理hibernate事务报异常--Transaction not successfully started解决方法
- hibernate 事务嵌套导致org.hibernate.TransactionException: Transaction not successfully started
- spring管理hibernate事务报异常--Transaction not successfully started解决方法
- Exception in thread "main" org.hibernate.TransactionException: Transaction not successfully started解
- 将Jar包中的文件拷贝到本地文件
- php模拟post提交数据,用处很多,可用来网站的采集,登陆等等
- ADO连接oracle数据库,并调用带参数的存储过程
- 国际金价本周连涨 “中国大妈”寻找心理安慰
- ActonBar介绍-修改actionbar的高度
- Transaction not successfully started 处理办法
- Pywinauto 基于Win32 程序的自动化功能测试工具
- hdu2007 平方和与立方和
- 基本概念--主磁盘分区、扩展磁盘分区、逻辑分区、物理分区
- POJ 3667 & 1823 Hotel (线段树区间合并)
- iOS 第五天
- tab选项卡
- HTML 文字行间距与文字间距属性
- 深入探讨集群存储高可用方法