使用场景:因为数据量比较大导致批量更新的时候失败文章来源:https://www.toymoban.com/news/detail-412570.html
int pageSize = 5000;
int totalSize = rewardAmounts.size();
int totalPage = totalSize / pageSize;
if (pageSize > totalSize) {
rewardAmountService.updateBatch(rewardAmounts);
} else {
for (int i = 0; i < totalPage; i++) {
rewardAmountService.updateBatch(rewardAmounts.subList(i * pageSize, (i + 1) * pageSize));
}
if (totalSize % pageSize != 0) {
rewardAmountService.updateBatch(rewardAmounts.subList(totalSize - totalSize % pageSize, totalSize));
}
}文章来源地址https://www.toymoban.com/news/detail-412570.html
到了这里,关于分批更新List数据的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!