1. 程式人生 > 其它 >com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: can not find lambda cache for this property [xxx] of entity [com.xxx.si.fss.ssf.ass.entity.xxx]

com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: can not find lambda cache for this property [xxx] of entity [com.xxx.si.fss.ssf.ass.entity.xxx]

 

因為MP3.2+之後不會快取實體類的父類欄位資訊,所以在使用泛型的Lambda表示式時會報錯.

{@code MybatisPlusException: can not find lambda cache for this entity [com.copm.ifm.base.basic.pojo.BaseTreePO]} 

原因是在執行{@link com.baomidou.mybatisplus.core.toolkit.LambdaUtils#getColumnMap(Class)}時

他會將所有掃描到的mapper中的泛型({@link BaseMapper<Class>}中的Class,即實體類)的欄位資訊快取到

{@link com.baomidou.mybatisplus.core.toolkit.LambdaUtils}中的{@code COLUMN_CACHE_MAP}中。

但是MP3.2+之後不會載入父類的資訊,所以{@code COLUMN_CACHE_MAP}中沒有相關快取,就報錯了。

因此我們單獨為{@link BaseTreePO}新增一個的Mapper類,這樣他就會快取該類的資訊了。

錯誤資訊如下:

com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: can not find lambda cache for this property [aricOrderNo] of entity [com.pcitc.si.fss.ssf.ass.entity.SsfAssRule]

總結:不適用 lambda查詢了,改用別的。