spring事务回滚
程序员文章站
2022-07-05 18:18:24
...
spring处理数据库事务回滚
1.注解方式
@Transactional(rollbackFor = {Exception.class})
public Boolean saveRecord(BusOrderRequest t) {
DataOne dataOne = new DataOne ();
DataTwo dataTwo= new DataTwo();
try {
dao.insert(dataOne );
dao.update(dataTwo);
} catch (Exception e) {
e.printStackTrace();
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return false;
}
return true;
}
上一篇: 事务回滚