今天在工作中使用mybatis plus的selectBatchIds(List<Integer> ids)方法时,oracle报了ORA-01795的错。

则是因为oracle中使用 in 有限制,后面集合数目不能大于1000个,否则就会报错。

所以可以使用这种形式来规避。

select   ...  from ...  where id  in (1,2...1000) or in (1001,1002...2000) or (2001....

所以当id集合大于1000时候,就不能用Mybatis plus了,要在xml中手写查询方法。

如下图:

ORA-01795 解决办法

 

经测试,最后的运行结果应该是这样:

select   ...  from ...  where id  in (1,2...998,null) or in (999...1997,null) or (1998....

 如果在Sql中不加上NULL,可能会形成这样的sql,直接报错。

select   ...  from ...  where id  in (1,2...998,) or in (999)

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-28
  • 2021-10-27
  • 2021-12-13
  • 2021-11-29
  • 2021-08-16
猜你喜欢
  • 2022-01-12
  • 2021-07-27
  • 2021-11-19
  • 2022-12-23
  • 2022-12-23
  • 2021-08-04
  • 2021-07-14
相关资源
相似解决方案