分批更新list

     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));
            }
        }

猜你喜欢

转载自www.cnblogs.com/kingxiaozi/p/11635378.html
今日推荐