commit a specific transaction nested within another transaction - coldfusion - hibernate

Viewed 87

there is a code snippet that needs to be executed even if the parent transaction enters catch and rollack

transaction action="begin" nested="true" isolation="read_uncommitted"{
  try{
    transaction {
      //more code...
    }
    transaction{
      //my code that needs to be committed anyway, even though the parent transaction of rollback
    }

  }catch(Any e){
     transaction action="rollback";
  }
}

this is a very simplified example of my current code. How do I force commit this single point of code?

1 Answers

Use a finally{} code block. See documentation here.

transaction action="begin" nested="true" isolation="read_uncommitted"{
  try{
    transaction {
      //more code...
    }
  }catch(Any e){
     transaction action="rollback";
  }finally {
    transaction{
      //my code that needs to be committed anyway, even though the parent transaction of rollback
    }
  }
}
Related