[jboss-user] [EJB 3.0] - how to rollback a DB manipulation SQL in a method

mrchit_2000 do-not-reply at jboss.com
Sun Mar 25 00:35:59 EDT 2007


Hi all,

I have this question regarding rolling back and I thought it is handled by Transaction Manager of the EJB 3.0 but it doesnot seem so. 
The problem is I have method in a Stateless session bean that trying to remove some rows in 1 table first and and then insert some rows in the other table. I want to make sure if the insertion failed in the second step, all of those removals would be rolled back. I use the EntityManager to do the delete and insert. Here are the pseudocode of my method

void updateDB (){
  | 
  |      removeRows();
  |      addRows();
  | }
  | void removeRows(){
  |    //use EntityManager to remove
  | }
  | 
  | void addRows(){
  |    //use EntityManager to insert some rows
  | }
  | 


Could anyone tell me how to make sure if the call to addRows failed, such as insert a duplicate row, would cause the removeRows rolledback?

Thank you very much in advance,

LNgo

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4031365#4031365

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4031365



More information about the jboss-user mailing list