交易和捕获块

时间:2015-11-04 10:31:20

标签: java transactions

如果第二个交易被回滚(即method3())会发生什么?首先是事务回滚吗?

//没有交易方法

method1()
{
  try{
       method2(); // transactional
       method3(); // transactional and fails due to exception
  }
  catch {
    return "error message";
  }

1 个答案:

答案 0 :(得分:2)

不,如果method3()失败,method2()的交易将不会回滚,因为它们是2个不同的交易。

注意:即使method1是事务性的,它也不能确保整个操作的原子性(method2 + method3),因为你正在捕获异常。

相关问题