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);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章