数据库回滚-@Transactional
作者:互联网
使用@Transactional,当方法内出现异常时进行数据库回滚
@Transactional(rollbackFor = Exception.class) @Override public BaseResponse approvalPerson(Person person) throws Exception{ BaseResponse response = new BaseResponse(); try { Boolean ret = personMapper.approvalPerson(person); if (ret && person.getStatus() == 2){ 。。。 } } catch (Exception e) { logger.error("approvalPerson error: ",e); response.setCode(DefaultErrorCode.ERROR.getCode()); response.setMsg("审批失败"); response.setData(e.getMessage()); throw new Exception("test4 error"); } return response; }
标签:回滚,BaseResponse,Transactional,Exception,数据库,person,approvalPerson,response 来源: https://www.cnblogs.com/lijianda/p/12736372.html