Hibernate TransactionException: Transaction not successfully started

Posted on November 13, 2010

0


If you got this cryptic error … among other issues … this could because you had one transaction embedded inside another.

MethodA(){

….

objectDAO.getSession().beginTransaction();

objectDAO.save(objectInstance);

MethodB();

objectDAO.getSession().getTransaction().commit()

….

}

MethodB(){

….

anotherObjectDAO.getSession().beginTransaction();//<===Begining a transaction inside another transaction … REMOVE THIS

anotherObjectDAO.save(anotherObjectInstance);

anotherObjectDAO.getSession().getTransaction().commit()//<===Begining a transaction inside another transaction … REMOVE THIS

….

}

You may have innocently done this … say when you write to a summary or reporting entity for every change to the transaction entity.

So remove the second transaction … it will work fine.

Advertisements
Posted in: Hibernate