事务的传播属性

  1. 私有方法出错,事务回滚
    @Override
    @Transactional
    public void addContract() {
        ContractEntity contract = new ContractEntity();
        contract.setContractType(ContractTypeEnum.PURCHASE_CONTRACT);
        contract.setContractStatus(ContractStatusEnum.APPROVED);
        contract.setDealerCode(7000001);
        contract.setCreateBy("test01");
        contract.setCreateTime(LocalDateTime.now());
        contractDomain.save(contract);
        addQuotation();
    }

    private void addQuotation() {
        QuotationEntity quotationEntity = new QuotationEntity();
        quotationEntity.setDealerCode(7000320);
        quotationEntity.setCompanyCode("123");
        quotationEntity.setStatus(QuotationStatusEnum.NEW);
        quotationEntity.setQuotationType(STOCK_QUOTATION);
        quotationEntity.setExtraPrice(new BigDecimal("100"));
        quotationEntity.setCashDiscountPrice(new BigDecimal("100"));
        quotationEntity.setSaleTotalPrice(new BigDecimal("100"));
        quotationEntity.setCreateBy("test02");
        quotationEntity.setCreateTime(LocalDateTime.now());
        quotationDomain.save(quotationEntity);
    }
原文地址:https://www.cnblogs.com/mengjianzhou/p/14480861.html