@Transactional回滚后是否继续引发catch异常

时间:2018-12-14 06:47:48

标签: java

@Transactional(propagation = Propagation.REQUIRED, rollbackFor = {
    Exception.class,
    RuntimeException.class
})
public void parent() {
    try {
        child();
    } catch (RuntimeException re) {
        //i want do something at here, how to catch the child RuntimeException 
        //child Transactional cath RuntimeException,can i catch it here?
    }
}

@Transactional(propagation = Propagation.MANDATORY, rollbackFor = {
    Exception.class,
    RuntimeException.class
})
public void child() {
    try {
        xxxMapper.update();
    } catch (Exception e) {
        throw new RuntimeException("false");
    }
}

子Transactional捕获RuntimeException并回滚

我在父母中称孩子为子,可以捕获此RuntimeException吗?

0 个答案:

没有答案