Spring でのネストされたトランザクション処理と伝播を理解したい以下のシナリオがあります。私は実際にこれについて十分に読みましたが、いくつかの事実についてはまだ不明でした.
public class ServiceImpl {
@Autowired
public AnotherService anotherService;
@Transactional // by default it is PROPOGATION_REQUIRED
public void insert (){
anotherService.anotherInsert();
}
}
public class AnotherServiceImpl {
@Transactional(propagation = Propagation.NESTED)
public void anotherInsert() {
insertSomeTestData();
}
private void insertSomeTestData() {
// call insert some test data recursively
// insert trasaction
insertSomeTestData();
}
}
このシナリオでanotherInsert
は、ネストされたデータをコミットし、一部のデータをロールバックします。これは、デフォルトである外側のトランザクションに影響しPROPOGATION_REQUIRED
ますか?また、不明な点は、トランザクションがネストされている場合、そのような場合に新しいものを開始しますか?