2020
11-29
11-29
巧妙mybatis避免Where 空条件的尴尬
我就废话不多说了,大家还是直接看代码吧~<selectid="findActiveBlogLike"resultType="Blog">SELECT*FROMBLOGWHERE<iftest="state!=null">state=#{state}</if></select>如果state参数为空时,最终生成SQL语句为SELECT*FROMBLOGWHERE执行会出错,当然,你可以在where后加一个1=1,改成<selectid="findActiveBlogLike"resultType="Blog">SELECT*FROMBLOGWHERE1=1<iftest="state!=null">andstate=...
继续阅读 >