当前使用版本(必填,否则不予处理)

3.4.2

该问题是如何引起的?(确定最新版也有问题再提!!!)

不同的实体数据库表,都有相同的查询条件,构造LambdaQueryWrapper时,期望不需要每个实体类都去处理一遍这些查询条件,相同的查询条件定义泛型方法来处理

重现步骤(如果有就写完整)

1,定义两个数据库实体,相同的字段放到基类Base

class Base {
  Long id;
  Long appId;
}

class A extends Base {
  String fieldA;
}

class B extends Base {
  String fieldB;
}

2,定义查询条件的泛型处理方法

protected <E extends Base> void handleAppId(LambdaQueryWrapper<E> qw, Long appId) {
        if (appId != null) {
            if (appId == -1L) {
                qw.eq(E::getAppId, -1L);
            } else {
                qw.and(t -> t.eq(E::getAppId, -1L)
                        .or().eq(E::getAppId, appId));
            }
        }
}

3,查询报错

报错信息

空指针异常,ColumnCache 字段缓存里面没有找到

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 [java.lang.NullPointerException]

com.github.yulichang.wrapper.MPJAbstractLambdaWrapper, getCache(), 57 com.github.yulichang.wrapper.MPJAbstractLambdaWrapper, columnToString(), 47 com.github.yulichang.wrapper.MPJAbstractLambdaWrapper, columnToString(), 36

Comment From: TannnnnnnnnnnnnnnnK

难道是mpj的问题,mp没有?