1.注解@Transactional
2.异常回滚 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@Override
@UDS(value="fq")
@Transactional
public BaseResultMessage testTransactional(){
BaseResultMessage rm = Utils.baseDefaultResultMessageSuccess();
TestEntity test = new TestEntity();
test.setId(5);
test.setName("xx");
int i = otherOrderInMapper.insetTest(test);
try{
int m=10/0;
}catch (Exception e) {
logger.error("==> 异常回滚!");
rm.setType(false);
rm.setMsg(" 异常回滚");
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
return rm;
}