因为当存在condition的条件时,就算condition为false,条件的值必须要传,但是其实是用不上的,比如:

SomeObject o = null; Wrappers.lambdaQuery().eq(o!=null,Entity::getCode, o.getCode()); //如果这么写是会有npe错误。

Comment From: wangzhanxu

o != null && o.getCode() != null不行吗?

Comment From: kongwang

o != null && o.getCode() != null不行吗?

可以的,但是前面已经有了条件o!=null,后面重新判断一次,有点重复; 而且在对于其他需要运算的条件下,多了一次没有必要的处理,某些时候对性能有影响。

Comment From: miemieYaho

使用 func 方法