改造前
...
cc.credit_id IN
<foreach collection="queryParam.creditIds" open="(" close=")" item="items" separator="," >
#{items}
</foreach>
问题: 单次in最多支持1000个
方案:最小改动方案,用or拼接多个in,效果 - - in() or in() or in()
改造后
...
(cc.credit_id IN
<foreach collection="queryParam.creditIds" open="(" close=")" item="items" index="index">
<if test="index != 0">
<choose>
<when test="index % 1000 == 999">) OR cc.credit_id IN (</when>
<otherwise>,</otherwise>
</choose>
</if>
#{items}
</foreach>
)
- index != 0 [ 避免 in 中开头为 , ]
- 每逢999 则拼接到新的in中