MyBatis中的参数失效情况
在写代码的过程中,需要在xml文件中写sql语句进行数据查询,但是测试的过程中发现deleteStatus和type参数为0的时候,相应的sql语句并没有成功拼接
select a.id, a.type, a.style_name, a.item_code, a.title, a.sale, a.technology, a.year,
a.delete_status, a.publish_status, a.new_status, a.recommend_status, a.hot_status,
a.keywords,a.img_url, b.price
from pm_item a
inner join(SELECT item_id,min(price) price FROM `pm_product` GROUP BY item_id) b on a.id = b.item_id
where 1=1
<if test="deleteStatus != null and deleteStatus !=''">
and a.delete_status=#{deleteStatus}
</if>
<if test="type != null and type !=''">
and a.type = #{type}
</if>
<if test="lowPrice != null and lowPrice !=''">
and b.price >= #{lowPrice}