标签:entity sub list 更新 ++ lse 批量更新 使用 each
红字部分代表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); } } }
【java】【mybatis】在使用mybatis进行批量插入,批量更新等批量操作时,切割In集合List进行分批批量操作的java中的切割代码
标签:entity sub list 更新 ++ lse 批量更新 使用 each
原文地址:https://www.cnblogs.com/sxdcgaq8080/p/9639388.html