FAQ-mybatis关于oracle-in-1000个数限制的解决

Oralce in 语句中当in(1,2,3…) 条件数量大于1000将会报错。

如果我们把in拆分成多个in就可以解决这个问题。
修改前

1
2
3
4
5
6
7
select *
from tbl_temp
where
id in
<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
#{item}
</foreach>
1
2
3
4
select *
from tbl_temp
where
id in (1,2,3)

修改后

1
2
3
4
5
6
select *
from tbl_temp
where
<foreach item="item" index="index" collection="ids" open="(" separator="or" close=")">
id in #{item}
</foreach>
1
2
3
4
select *
from tbl_temp
where
(id in 1 or id in 2 or id in 3)