JDO Local Transaction Management -


in jdo in situation described below, after methodb() executed (which has been called methoda() ), if exception occurs in methoda() rollback take place code both in methoda() , methodb() or methoda() in methodb() commit has taken place. note: persistencemanager created on demand , stored in threadlocal

methoda(){   persistencemanager mgr = getpersistencemanager(  );     transaction trans;      trans = mgr.currenttransaction(  );     try {         trans.begin(  );         methodb();          //some delete/update code         // exception occurs          trans.commit(  );             }     catch( exception e ) {         e.printstacktrace(  );     }     {         if( trans.isactive(  ) ) {             trans.rollback(  );         }         mgr.close(  );     } 

}

methodb(){

    persistencemanager mgr = getpersistencemanager(  );     transaction trans;      trans = mgr.currenttransaction(  );     try {         trans.begin(  );         //code         trans.commit(  );             }     catch( exception e ) {         e.printstacktrace(  );     }     {         if( trans.isactive(  ) ) {             trans.rollback(  );         }         mgr.close(  );     } 

}

transactions not nested, independent. pms different txns different. 1 fails rolls back, , nothing other one


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -