【java】【mybatis】在使用mybatis进行批量插入,批量更新等批量操作时,切割In集合List进行分批批量操作的java中的切割代码

      
红字部分代表mybatis的批量操作调用方法:

       int
num = 0; int maxLength = 200; int size = usableCodes.size(); if (size <= maxLength) { bean = createBean(bean,entity,usableCodes); num = receiptMapper.receipt(bean); } else { // 计算循环次数 int eachTime = (size / maxLength) + 1; for (int i = 0; i < eachTime; i++) { int fromIndex = 0; int toIndex = 0; fromIndex = (i * maxLength); toIndex = (fromIndex + maxLength); if (i + 1 == eachTime) { toIndex = usableCodes.size(); } List<String> subList = usableCodes.subList(fromIndex, toIndex); if (subList.size() > 0) { bean = createBean(bean,entity,subList); num += receiptMapper.receipt(bean); } } }

 

posted @ 2018-09-13 11:15  Angel挤一挤  阅读(640)  评论(0编辑  收藏  举报