分批存储数据入库

50 阅读1分钟

这里假设一次存1000条

int batchSize = 1000;
for (int i = 0; i < customerQualificationsRankListSet.size(); i += batchSize) {
    int endIndex = Math.min(i + batchSize, customerQualificationsRankListSet.size());
    List<HyzsCustomerQualificationsRank> batch = customerQualificationsRankListSet.subList(i, endIndex);
    hyzsCustomerQualificationsRankService.saveBatch(batch);
}