mybatis 中批量数据插入,分批提交

1、留作记录,直接上代码

logger.info("list.size()===>" + list.size());//数据源
int cont = 0;
for (int i = 0; i < list.size() / 400 + 1; i++) {
    int temp = (i + 1) * 400;
    if (temp >= list.size()) {
        temp = list.size();
    }
    List<Map<String, Object>> rowsList = list.subList(i * 400, temp);
    //提交的方法
    cont += xnyqxgzzbMapper.batchInsert(rowsList);
}
logger.info("更新的行数cont===>" + cont);

猜你喜欢

转载自blog.csdn.net/CHL123456789/article/details/103387083