当前位置: 代码迷 >> J2EE >> org.springframework.transaction.TransactionSystemException:
  详细解决方案

org.springframework.transaction.TransactionSystemException:

热度:625   发布时间:2016-04-22 02:08:13.0
添加成功了!但是报错了!
org.springframework.transaction.TransactionSystemException: Could not commit Hibernate transaction; nested exception is org.hibernate.TransactionException: Transaction not successfully started
org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:660)
org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:393)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)




数据库添加成功了!但是页面报了这个错!

------解决方案--------------------
报的是事物没有开启。。
------解决方案--------------------

Could not commit Hibernate transaction; 


Transaction not successfully started
事务没有开启



Java code
//最好放在try catch里, try{Session s = HibernateUtil.getSession();//从hibernateUtil拿到sessionTransaction tx = s.getTransaction();//设置事务tx.begin();//开启事务 //do something...tx.commit();//提交事务}catch(Exception e){     //捕获异常    // 并且在catch里回滚事务}
------解决方案--------------------
org.springframework.transaction.TransactionSystemException: Could not commit Hibernate transaction; nested exception is org.hibernate.TransactionException: Transaction not successfully started

事务 Transaction 没有开启
  相关解决方案