Sunday, December 21, 2008

Transaction not successfully started

I got an exception : org.hibernate.TransactionException: Transaction not successfully started

The problem in my code was :
Session session = null; Transaction tx = null; session = PriorityWrapperHibernateUtil.getOneTimeSession(); tx = session.getTransaction(); for (int i = 0; i < objects.length; i++) { Object object = objects[i]; session.saveOrUpdate(object); } if(tx != null){ tx.commit(); }


instead, it should be : tx = session.beginTransaction();

I used the Koders site to find out where the exception is comming from

No comments: