public void batchInsert(int batchNum, List<Long> siteIdList) {
batchNum = 50;
//插入db的数据
List<Long> siteIds = new ArrayList();
int i = 0;
for (Long siteId : siteIdList) {
if (i % batchNum == 0 && i >= batchNum) {
//插入db
//并清除siteIds
siteIds.clear();
} else if (i % batchNum != 0 && i == (siteIdList.size() - 1)) {
//插入db
//并清除siteIds
siteIds.clear();
}
siteIds.add(siteId);
i++;
}
}
网友评论