yulichang / mybatis-plus-join

支持连表查询的mybatis-plus,mybatis-plus风格的连表操作提供wrapper.leftJoin(),wrapper.rightJoin()等操作
https://yulichang.github.io/mybatis-plus-join-doc/
Apache License 2.0
1.01k stars 115 forks source link

多个条件构造器使用,报空指针问题 #42

Closed HELLFS closed 1 year ago

HELLFS commented 1 year ago

连表查询时,多个条件构造器连续使用condition参数来控制SQL是否拼接,当condition参数传入 对布尔包装类型参数的null判断 会出现空指针异常问题,还有LocalDateTime数组 对象 null值判断 ,其他类型暂未出现

yulichang commented 1 year ago

有代码吗? 我猜可能是这样或者类似的使用方式

List<String> list = null;
wrapper.eq(null != list, User::getId, list.get(0))

这么写一定会报空指针, 这是由java方法调用的机制决定的, 用Mybatis Plus原生的wrapper也会报同样的错误 可以换种写法

List<String> list = null;
if(null != list){
    wrapper.eq(User::getId, list.get(0))
}

或者

List<String> list = null;
wrapper.and(null != list, w -> w.eq(User::getId, list.get(0)))

如果不是这种情况, 可以贴上代码, 重新打开这个 issue

HELLFS commented 1 year ago

image 选中的参数 都是默认值,走到选中参数对应的条件构造器时就会报空指针问题 这种情况