事物手动回滚之TransactionAspectSupport.currentTransactionStatus().setRollbackOnly()

@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public RespData addLandOwner(CustomerDTO customerDTO) {
try {

        Landowner landOwner = new Landowner();
        BeanUtils.copyProperties(customerDTO,landOwner);
        if(landOwnerMapper.insertSelective(landOwner)<1){
            return RespData.fail(RespData.FAIL_CODE,"新增客户失败");
        }
        //新增成功后  往旧表里落一份数据
        syncAddLandOwner(landOwner);

    } catch (Exception e) {
        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        return RespData.fail("新增客户失败");
    }
}

版权声明:本文为saj123456原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。