【PowerMockito:编写单元测试过程中使用LambdaUpdateWrapper时set方法can not find lambda cache for this entity的问题】
【代码】【PowerMockito:编写单元测试过程中使用LambdaUpdateWrapper时set方法can not find lambda cache for this entity的问题】
·
错误描述
PowerMockito:编写单元测试过程中使用LambdaUpdateWrapper时set方法can not find lambda cache for this entity的问题,代码如下:
Wrapper<ImageInfoPo> wrapper = new LambdaUpdateWrapper<ImageInfoPo>()
.eq(ImageInfoPo::getTemplateId, reqDto.getTemplateId())
.set(ImageInfoPo::getImageStatus, ImageStatusEnum.DELETING.code());
执行到断点处出错,报错如下
com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: can not find lambda cache for this entity [com.chinamobile.cmss.cementity.domain.ImageInfoPo]
解决方案
解决的方案是手动触发相关缓存信息收集,添加如下代码:
@BeforeEach
public void initTable() {
TableInfoHelper.initTableInfo(new MapperBuilderAssistant(new MybatisConfiguration(), ""), Xxx.class);
}
或者
@Before
public void init() {
TableInfoHelper.initTableInfo(new MapperBuilderAssistant(new MybatisConfiguration(), ""), Xxx.class);
}
更多推荐
所有评论(0)