@PostMapping("/save") @ApiOperation("新增或修改客户") @DataSource(DataSourceEnum.erpDB) @Transactional(propagation = Propagation.REQUIRED) //事务回滚,在有transaction状态下执行;如当前没有transaction,则创建新的transaction public ResponseData save(@RequestBody CustomerExtVo record) {return ResponseUtil.success(bdCustomerService.saveCustomerInfo(record)); }
Propagation取值:
REQUIRED(默认值):在有transaction状态下执行;如当前没有transaction,则创建新的transaction;
SUPPORTS:如当前有transaction,则在transaction状态下执行;如果当前没有transaction,在无transaction状态下执行;
MANDATORY:必须在有transaction状态下执行,如果当前没有transaction,则抛出异常IllegalTransactionStateException;
REQUIRES_NEW:创建新的transaction并执行;如果当前已有transaction,则将当前transaction挂起;
NOT_SUPPORTED:在无transaction状态下执行;如果当前已有transaction,则将当前transaction挂起;
NEVER:在无transaction状态下执行;如果当前已有transaction,则抛出异常IllegalTransactionStateException。