需求:xml中传入参数中包含一个list,需要在where中拼接in语句
假设查询person表,参数类型为XXXVo,XXXVo中包含一个List对象,保存了状态列表,此时可以参考如下查询
<select id="queryXXX" parameterType="XXXVo"
resultMap="XXXResult">
select *
from person
WHERE 1=1
<if test="statusFilter != null and statusFilter.size() > 0">
and status in
<foreach collection="statusFilter" item="statusId" index="i" open="(" close=")" separator=",">
#{statusId}
</foreach>
</if>
ORDER BY DEPTID
</select>