分批更新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));
            }
        }

 

posted @ 2019-10-08 14:53  海天依色  阅读(331)  评论(0编辑  收藏  举报