mybatis动态查询Integer类型入参为0不生效的问题

解决

//Integer类型入参,动态sql判断只需要判null即可
<if test="status != null "> and status = #{status}</if>

原因

mybatis源码在预编译sql时,使用OGNL表达式来解析if标签,对于Integer类型属性,(status != '')会当作(status!=0)来判断

 

posted @ 2023-08-17 09:58  白玉神驹  阅读(88)  评论(0)    收藏  举报