我们通过声明式方法使用事务管理,我们指定所有以update*开头的方法都必须遵循事务。
假设我们在此方法中有一个事务方法updatePayroll(),我们正在调用另外四个方法,但我们的要求是仅在前两个方法失败的情况下回滚,否则不需要回滚。我不知道如何实现这一点,因为我的updatePayroll()是事务处理方法,所以如何告诉 spring 我们只需要两个updatePayroll()方法进行事务处理。
代码:
public void updatePayroll()
{
// below two methods of updateParyroll is required transaction where updatePayroll is transacted method through declarative approach.
updateLWPEmployees();
processSalary();
// below methods does not require transaction.
printSalarySlip();
sendEmail();
}
提前致谢。