jfinal
/**
* 批量保存
*
* @param modelList
*/
public void batchSave(List modelList) {
// 判断list的大小,如果大于200条,则size/200分批次保存
int size = modelList.size();
if (200 >= size) {
Db.batchSave(modelList, size);
return;
}
int serial = size / 200;
for (int i = 0; i < serial; i++) {
Db.batchSave(modelList.subList(i * 200, i * 200 + 200), 200);
}
int remain = size - serial * 200;
Db.batchSave(modelList.subList(serial * 200, size), remain);
}
}