Mungkin saya salah memahami perilaku Spring Requires_new. Ini kode saya:
@Transactional(rollbackFor=Exception.class,propagation=Propagation.REQUIRED)
public void outterMethod() throws Exception{
innerMethod1();
innerMethod2();
}
@Transactional(rollbackFor=Exception.class,propagation=Propagation.REQUIRES_NEW)
public void innerMethod1() throws Exception{
testService.insert(new Testbo("test-2", new Date()));
}
@Transactional(rollbackFor=Exception.class,propagation=Propagation.REQUIRES_NEW)
public void innerMethod2() throws Exception{
testService.insert(new Testbo("test-2", new Date()));
throw new Exception();
}
Ketika innnerMethod2 melontarkan Exception, saya pikir innerMethod1 masih dapat melakukan. Namun semua transaksi luar dan dalam dikembalikan. Apa yang salah saya di sini? Bagaimana yang bisa saya lakukan untuk melakukan innerMethod1 ketika innerMethod2 melakukan rollback?