美文网首页
MybatisPlus报错 can not find lambd

MybatisPlus报错 can not find lambd

作者: 饱饱想要灵感 | 来源:发表于2024-06-13 15:25 被阅读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) ;
    

    相关文章

      网友评论

          本文标题:MybatisPlus报错 can not find lambd

          本文链接:https://www.haomeiwen.com/subject/ghhoqjtx.html