ฉันอาจเข้าใจผิดพฤติกรรมของ Spring Requires_new นี่คือรหัสของฉัน:
@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();
}
เมื่อ innnerMethod2 ส่ง Exception ฉันคิดว่า InnerMethod1 ยังคงสามารถคอมมิตได้ แต่การย้อนกลับของธุรกรรมภายนอกและภายในทั้งหมด ฉันผิดอะไรที่นี่? ฉันจะทำอย่างไรเพื่อคอมมิต InnerMethod1 เมื่อย้อนกลับ InnerMethod2