确认
- [X] 我的版本是最新版本, 我的版本号与 version 相同, 并且项目里无依赖冲突
- [X] 我已经在 issue 中搜索过, 确认问题没有被提出过
- [X] 我已经修改标题, 将标题中的 描述 替换为遇到的问题
当前程序版本
3.5.7
问题描述
批量新增 insert(Collection
package com.cn.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName("tb_entity")
public class Entity {
@TableId
private String id;
}
package com.cn.service;
import cn.hutool.core.collection.ListUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cn.dao.EntityDAO;
import com.cn.entity.Entity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
@Service
public class MyService {
@Resource
private EntityDAO entityDAO;
@Transactional
public List<Entity> queryAndInsert(){
List<Entity> list = entityDAO.selectList(new LambdaQueryWrapper<>());
System.out.println(list.size());
Entity entity = new Entity();
entity.setGid("123");
//entityDAO.insert(entity);//可以刷新缓存
entityDAO.insert(ListUtil.of(entity));//无法刷新缓存
System.out.println("------------------进行查询---------------");
list = entityDAO.selectList(new LambdaQueryWrapper<>());
System.out.println(list.size())
;
if (list.size() == 1) {
throw new RuntimeException("缓存刷新");
}
if (list.size() == 0) {
throw new RuntimeException("缓存未刷新 未执行第二次查询");
}
return list;
}
}
package com.cn.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import com.cn.entity.Entity;
@Mapper
public interface EntityDAO extends BaseMapper<Entity> {
}
详细堆栈日志
No response