码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • java 事务提交(批量处理数据,单个批次执行完成后直接提交事务)


    方法一:接口+REQUIRES_NEW 实现单个事务提交

    方式1:
    for (TIrBuPBom buPBom : batchList) {
       // 查询待处理的批次数据
      List<TIrBuPBom> pBomList = pBomMapperBase.list(new LambdaQueryWrapper<TIrBuPBom>()
                            .eq(TIrBuPBom::getBatchNo, buPBom.getBatchNo())
                            .eq(TIrBuPBom::getCarTypeCode, buPBom.getCarTypeCode())
                            .eq(TIrBuPBom::getDealStatus, "0"));
    if (pBomList.size() == buPBom.getBatchSl()) {
    	// 通过接口+ @Transactional(propagation = Propagation.REQUIRES_NEW)实现,单个事务提交
     	itIrBuPBomBiz.dealBomBatch(buPBom, pBomList, plantListMap, wkShopListMap, userName, now, tenancyId);
    } else {
    	 break;
    }
    }
    
     @Transactional(propagation = Propagation.REQUIRES_NEW)
        public void dealBomBatch(TIrBuPBom buPBom, List<TIrBuPBom> pBomList, Map<String, List<Map<String, String>>> plantListMap, Map<String, List<Map<String, String>>> wkShopListMap, String userName, LocalDateTime now, String tenancyId) {
    
    ....}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19

    方法二:手动提交

     if (pBomList.size() == buPBom.getBatchSl()) {
                        // 手动提交事务
                        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
                        def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
                        def.setIsolationLevel(2);
                        TransactionStatus status = null;
                        try {
                            status = this.platformTransactionManager.getTransaction(def);
                        this.dealBomBatch(buPBom, pBomList, plantListMap, wkShopListMap, userName, now, tenancyId);
                            this.platformTransactionManager.commit(status);
                        } catch (Exception var18) {
                            this.platformTransactionManager.rollback(status);
                            throw new BusicenException(var18.toString());
                        }
    
                    } else {
                        break;
                    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
  • 相关阅读:
    openjudge 1.8.5 计算鞍点
    《30天吃掉那只 TensorFlow2.0》 3-3 高阶API示范
    【Python百日进阶-Web开发-Feffery】Day400 -“一起Dash”训练营Lesson-09_利用多页面应用_课堂
    ZYNQ_FPGA_SPI通信协议多种实现方式
    8、【STM32】定时器(TIM)——中断、PWM、输入捕获实验(一文精通定时器)
    rocketmq-exporter配置为系统服务-自启动
    qt example plugandpaint 插件 动态库 pnp_extrafiltersd.dll无法加载问题
    浅析MySQL-基础篇01
    用于标记蛋白质和抗体的Biotin-LC-Sulfo-NHS|CAS:191671-46-2
    Day15: C++之STL容器(3/3)
  • 原文地址:https://blog.csdn.net/zh555888/article/details/134561542
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号