if (messageVariableList.size()>0){
//一次500条
int applyIdSelectSize = 500;
int limit = (messageVariableList.size() + applyIdSelectSize - 1) / applyIdSelectSize;
//分成limit次发请求到数据库,in()操作时 可以把多条数据分割成多组请求
Stream.iterate(0, n -> n + 1).limit(limit).forEach(a -> {
List<MessageVariable> paperEntityList = messageVariableList.stream().skip(a * applyIdSelectSize).limit(applyIdSelectSize).collect(Collectors.toList());
messageVariableMapper.insertMessageVariableAll(paperEntityList);
});
}
mybatis批量分批插入 stream流方式
最新推荐文章于 2024-05-07 11:22:25 发布
关键词由CSDN通过智能技术生成