问题描述
在进行搜索测试时,当参数为0,mybatis不识别
在mybatis中,参数类型为Integer或者Long时传入参数为0 将默认为false(为空:例 status=’’),不生效。
<if test="status != ''">
and orders.status = #{status,jdbcType=INTEGER}
</if>
在数据库中测试是生效的
解决方案
1.添加一个为0判断or status == 0
<if test="status != '' and status != null or status == 0">
and orders.status = #{status,jdbcType=INTEGER}
</if>
2.去除为空字符判断
<if test="status != null">
and orders.status = #{status,jdbcType=INTEGER}
</if>