我有一个EJB,它执行一些DB操作,然后在JNDI查找之后调用另一个EJB,它执行更多的DB操作。第二个EJB调用可能抛出一些异常,即PersistenceException (我在代码中查看了此异常将事务标记为仅回滚)。有什么方法可以避免事务回滚吗?下面是总结这个问题的代码。提前感谢。
public class Test {
ejbMthod1() {
// This method run under transaction
// Do some DB operation like update\delete
if(somecondition) {
try {
// JNDI lookup for ejb2
ejbMethod2();
}
catch(Exception ex){
// Will catching the exception here save the Transaction from rollback ?
// Is there any way I can avoid this rollback just by handling proper exceptions ?
}
}
}
}
class Test2 {
ejbMethod2() {
// Run under same transaction as caller
// do some DB operation which can throw many exception i.e. PersistenceException.
}
}https://stackoverflow.com/questions/44421901
复制相似问题