// 批量插入,手动控制事务
SqlSession batchSqlSession = null;
try {
    batchSqlSession = sqlSessionTemplate.getSqlSessionFactory()
        .openSession(ExecutorType.BATCH, false);// 获取批量方式的sqlsession
    int batchCount = 1000;// 每批commit的个数
    int batchLastIndex = batchCount - 1;// 每批最后一个的下标
    for (int index = 0; index < saveList.size();) {
        if (batchLastIndex > saveList.size()) {
            batchLastIndex = saveList.size();
            batchSqlSession.insert(
                "com.jomoo.oms.baseData.mapper.CapaCityMapper.create2",
                saveList.subList(index, batchLastIndex));
            batchSqlSession.commit();
            break;// 数据插入完毕,退出循环
        } else {
            batchSqlSession.insert(
                "com.jomoo.oms.baseData.mapper.CapaCityMapper.create2",
                saveList.subList(index, batchLastIndex));
            batchSqlSession.commit();
            index = batchLastIndex;// 设置下一批下标
            batchLastIndex = index + (batchCount - 1);
        }
    }
} catch (Exception e) {
    throw new OptException(e.getMessage());
} finally {
    batchSqlSession.close();
}
<insert id="create2"  parameterType="com.jomoo.oms.baseData.model.CapaCityModel">
    <selectKey keyProperty="id" order="BEFORE" resultType="Long">
        select JOMOO_OMS.OMS_CAPACITY_S.NEXTVAL as id from dual
    </selectKey>

    insert into JOMOO_OMS.OMS_CAPACITY(<include refid="Base_Column_List"></include>) select JOMOO_OMS.OMS_CAPACITY_S.NEXTVAL, A.*
    from (
    <foreach collection="list" item="capacity" index="index" open="" close="" separator="union all">
        select
        #{capacity.factoryCode},
        #{capacity.factoryName},
        #{capacity.productSeriesCode},
        #{capacity.productSeries},
        #{capacity.materialCode},
        #{capacity.materialName},
        #{capacity.dateNumber},
        #{capacity.totalCapacity},
        #{capacity.leftCapacity},
        #{capacity.remark},
        #{capacity.registerId},
        #{capacity.createdByEmployee},
        #{capacity.createdByDept},
        #{capacity.enableFlag},
        sysdate
        from dual
    </foreach>
    ) A
</insert>

最新文章

  1. PHP设计模式(七)适配器模式(Adapter For PHP)
  2. Codeforces Round #366 (Div. 2)
  3. Selenium Webdriver元素定位的八种常用方式
  4. oracle数据库表空间文件收缩实例
  5. mp3 切割
  6. Web API接口 安全验证
  7. C++学习笔记-1-自增和自减运算符
  8. android入门——UI(6)——ViewPager+Menu+PopupWindow
  9. python文件操作_对文件进行复制拷贝_代码实现
  10. java日期详解
  11. openstack第三章:nova
  12. 不使用接口的 limit 控制分页的容量
  13. Linux-01初级学习
  14. Python3学习笔记33-正则表达式
  15. Windows 10 Install rabbitmq-server-3.6.9
  16. Java泛型的一些限制
  17. window.location属性用法及解决一个window.location.search为什么为空的问题
  18. spark本地环境的搭建到运行第一个spark程序
  19. Jquery js框架使用
  20. redis系列:基于redis的分布式锁

热门文章

  1. 【互动问答分享】第8期决胜云计算大数据时代Spark亚太研究院公益大讲堂
  2. 获取apk的appPackage和appActivity方法
  3. (1) Flutter android studio安装
  4. Maven学习笔记3
  5. 洛谷——P2371 EXCEEDED WARNING C(50)
  6. Proxy(2016山东省省赛C)(最短路)(spfa)
  7. 9、Flask实战第9天:类视图
  8. 【mybatis】idea中 mybatis的mapper类去找对应的mapper.xml中的方法,使用插件mybatis-plugin
  9. [干货]2017已来,最全面试总结——这些Android面试题你一定需要
  10. unity3d开发app的框架