com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: can not find lambda cache for this entity

异常提示:  com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: can not find lambda cache for this entity

 


使用 mockito 框架做单元测试:
mybatisplus 使用 Lambda 表达式做条件查询、条件更新时会遇到 mybatis 拿不到缓存问题:

错误 1:com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: can not find lambda cache for this entity
错误 2:can not find lambda cache for this property [XXX] of entity [com.XXX.XXX]

解决方法:
在 LambdaQueryWrapper<TaskPO> 或 LambdaUpdateWrapper<TaskPO> 条件之前添加以下语句

TableInfoHelper.initTableInfo(new MapperBuilderAssistant(new MybatisConfiguration(), ""), 条件类名.class);

比如 TableInfoHelper.initTableInfo(new MapperBuilderAssistant(new MybatisConfiguration(), ""), TaskPO.class);

 

补充

IntelliJ IDEA 添加单元测试插件 TestMe

 

posted @ 2024-08-09 15:02  hapday  阅读(63)  评论(0编辑  收藏  举报