“java.sql.SQLException: ORA-01795: 列表中的最大表达式数为 1000”
第一种方法:
大致意思:把超过900条拆开,index是当前第几个数,除900取余数899,不就是第899次吗,就分开成两个 in 就行了,下次到899就在拆分一次,
and (USER.UNIT_ID in
<foreach collection="queryIds" index="index" item="item" open="(" close=")" separator=",">
<if test="(index % 900) == 899">NULL) or USER.UNIT_ID in (</if>
#{item}
</foreach>)
第二种方法:(适用于数据从数据库来的)
用子查询代替、子查询不会触发到1000的上限
and (USER.UNIT_ID in (select ID from T_DEPT where ID = ...))