版权声明:作者写博是为了总结经验,和交流学习之用。 如需转载,请在文章页面明显位置给出原文连接。谢谢!如有问题,请留言! https://blog.csdn.net/changqing5818/article/details/84309562
直接上SQL吧,思路很简单:
select * from test_table
where 1 = 1
<!-- IdList -->
<if test="IdList != null and IdList.size > 0">
AND PK_ID IN
<!-- 处理in的集合超过1000条时Oracle不支持的情况 -->
<trim suffixOverrides=" OR PK_ID IN()"> <!-- 表示删除最后一个条件 -->
<foreach collection="IdList" item="Id" index="index" open="(" close=")">
<if test="index != 0">
<choose>
<when test="index % 1000 == 999">) OR PK_ID IN (</when>
<otherwise>,</otherwise>
</choose>
</if>
#{Id}
</foreach>
</trim>
</if>