当前使用版本(必填,否则不予处理)
当前使用版本:3.3.2
该问题是如何引起的?(确定最新版也有问题再提!!!)
使用Wrappers.
重现步骤(如果有就写完整)
public class BaseServiceImpl
public Long check(T t) {
T one = getOne(Wrappers.<T>lambdaQuery()
.eq(T::getId, t.getId())
);
return one == null ? null : one.getId();
}
}
报错信息
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error evaluating expression 'ew.sqlSegment != null and ew.sqlSegment != '' and ew.nonEmptyOfWhere'. Cause: org.apache.ibatis.ognl.OgnlException: sqlSegment [com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: can not find lambda cache for this entity [com.mp.demo.entity.BaseInfo]]
报错信息来自这个方法: private String getColumn(SerializedLambda lambda, boolean onlyColumn) throws MybatisPlusException { String fieldName = PropertyNamer.methodToProperty(lambda.getImplMethodName()); Class<?> aClass = lambda.getInstantiatedType(); if (!initColumnMap) { columnMap = LambdaUtils.getColumnMap(aClass); initColumnMap = true; } Assert.notNull(columnMap, "can not find lambda cache for this entity [%s]", aClass.getName()); ColumnCache columnCache = columnMap.get(LambdaUtils.formatKey(fieldName)); Assert.notNull(columnCache, "can not find lambda cache for this property [%s] of entity [%s]", fieldName, aClass.getName()); return onlyColumn ? columnCache.getColumn() : columnCache.getColumnSelect(); } 因为传入的为子类而aClass获取到的为基类,而在getColumnMap中的map缓存构建时是不会将实体类的基类放进去的,导致一直为空。
Comment From: miemieYaho
.setEntityClass
Comment From: 1146604040
谢了。