1

I have methodA calling methodB. MethodB throwing some exception. What i want even if there some exception in methodB there is no rollback . I can not change methodB. Is there a way to handle at methodA level ?

@Transactional(noRollbackFor = Exception.class)
methodA() {
    ...
    try {

    for(Employee emp : employees){
          methodB();
        }
    } catch (...) {...}
    log("OK");
}

@Transactional
methodB() {
    // some exception is thrown
}

There is similar thread at Transaction marked as rollback only: How do I find the cause but looks like accepeted answer handled it at methodB level instead of calling method ?

Community
  • 1
  • 1
emilly
  • 10,060
  • 33
  • 97
  • 172
  • you can achieve this if method B and method A has different Exception throwing possibilities, write catch blocks in method A for the exceptions thrown by method B and handle it(don't rollback here) – RishiPandey Nov 15 '16 at 12:32

0 Answers0