Mybatis-plus: 3.12版本中selectStrategy(whereStrategy)设置为NOT_EMPTY 使用lamda表达式时依然回座位参数传递

Created on 5 Jul 2019  ·  6Comments  ·  Source: baomidou/mybatis-plus

image

image

Uploading image.png…
不知道算不算bug

Most helpful comment

whereStrategy仅在使用wrapper.entity作为条件时才生效:
QueryWrapper.setEntity(new User().setName(""));
当name配置为NOT_NULL, 生成where->
<if test="wrapper.entity.name!=null">and name=#{name}</if>
默认是
<if test="wrapper.entity.name!=null and wrapper.entity.name!=''">and name=#{name}</if>

All 6 comments

selectStrategy 和那个无关

可以举一个whereStrategy 的标准用法吗,我认为的是如果 设置了某个字段为NOT_EMPTY(默认参考配置文件,配置文件中我设置了NOT_EMPTY) lamdaquery使用eq或者其他表达式时,就会动态拼接sql

只对 wrapper 内的 entity 生效

建议以后可以集成到query中,我现在又要把我的狗皮膏药贴回去了. 尴尬.jpg

我倒是建议你先去了解完原理了再来提建议

whereStrategy仅在使用wrapper.entity作为条件时才生效:
QueryWrapper.setEntity(new User().setName(""));
当name配置为NOT_NULL, 生成where->
<if test="wrapper.entity.name!=null">and name=#{name}</if>
默认是
<if test="wrapper.entity.name!=null and wrapper.entity.name!=''">and name=#{name}</if>

Was this page helpful?
0 / 5 - 0 ratings