**数组判断**
==数组要判断长度的大小,防止空数据进行执行==
**vo.exportIds!= '' 是不正确的,会报错误 **
<if test="vo.exportIds!=null and vo.exportIds.length>0 ">
AND temp.rowno IN
<foreach collection="vo.exportIdes" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
**集合判断**
**集合不是对象**
<if test="vo.queryParams!=null and vo.queryParams.size()>0 ">
AND temp.rowno IN
<foreach collection="vo.queryParams" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
**集合是对象**
**separator 是连接字符(OR)**
<if test="vo.queryParams!=null and vo.queryParams.size()>0 ">
AND
<foreach collection="vo.queryParams" index="index" item="item" open="(" separator=" OR " close=")">
(
a.WRTR_COD = #{item.owrtr}
and
a.WRAT_COD = #{item.owrat}
and
a.RISK_TYP = #{item.oRiskType}
)
</foreach>
</if>
// 多个IN会出现笛卡尔积的情况,故将IN变成小段小段的OR来代替
Mybatis sql List集合和数组判断
最新推荐文章于 2023-07-03 21:35:20 发布