Search code examples
javaspringibatis

Code inside loops does not rollback in Spring Transaction


I'm having the following structure of code in the service class. The problem is in the event of the exception, the transaction only rollback for "insert A()". I'm using spring-ibatis.

function save
{
 insert A();

 for loop_1()
 {
   insert B()
   insert C()
   insert D() 
 }

 for loop_2()
 {
  insert E()   
  insert F()  --> throws RunTimeException
 }
}

Solution

  • Thank you all, I didn't notice one of my tables is not InnoDB (I'm using mysql). I changed it to InnoDB and now the transaction is working.