MybatisPlus报错 can not find lambd

2024-06-13  本文已影响0人  饱饱想要灵感

错误信息如下:

com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: can not find lambda cache for this entity com.copm.ifm.base.basic.pojo.BaseTreePO

// 或者
com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: can not find lambda cache for this property treeNo of entity com.copm.ifm.base.basic.pojo.BaseTreePO

因为MybatisPlus3.2+之后不会缓存实体类的父类字段信息,所以在使用父类的Lambda表达式时会报错.

具体是在执行com.baomidou.mybatisplus.core.toolkit.LambdaUtils#getColumnMap(Class)时,MybatisPlus会将Mapper中的实体类(即BaseMapper<Class>的Class)字段信息,缓存到com.baomidou.mybatisplus.core.toolkit.LambdaUtilsCOLUMN_CACHE_MAP中。

但是MybatisPlus3.2+之后不会加载父类的信息了,所以COLUMN_CACHE_MAP中没有相关缓存,于是报错了。

因此解决方案是, 手动将BaseTreePO添加到缓存中。代码如下:

TableInfoHelper.initTableInfo(new MapperBuilderAssistant(new MybatisConfiguration(), ""), BaseTreePO.class) ;
上一篇下一篇

猜你喜欢

热点阅读