Find the reason for not rolling back

Accidentally found that a block function of the system was abnormal, and the database update was not rolled back. After reading the code, I did the experiment myself. Two cases:
the first one:
@Override
public void overDueDeductSuccess2() throws Exception {
updateRepayData2();
throw new NullPointerException();
}

private void updateRepayData2() throws Exception {
String sql = "update t_customer t set t.real_name=' Qi Linyi 1' where t.id=5413";
jdbcDao.execute(sql);
}


The controller layer calls the overDueDeductSuccess2 method of the service layer, and @Transactional(rollbackFor = Exception.class) is added to the service layer class to roll back the test results .

The second type: service is called layer by layer, there is a service in the middle without @Transactional, it is a common class and does not implement the interface, and it is rolled back. The
third type : flush() is performed after the update is
found ; The last service only has @Transactional written on it, and there is no rollbackFor = Exception.class.
Finally, I found that all these cases were rolled back, okay

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326221030&siteId=291194637