Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/371.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java NamedParameterJdbcTemplate不';当第100条或第1000条中规定的值超过100或1000时,不工作_Java_Spring - Fatal编程技术网

Java NamedParameterJdbcTemplate不';当第100条或第1000条中规定的值超过100或1000时,不工作

Java NamedParameterJdbcTemplate不';当第100条或第1000条中规定的值超过100或1000时,不工作,java,spring,Java,Spring,我正在使用NamedParameterJdbcTemplate运行我的查询。查询如下: SELECT id, desc FROM tableA WHERE id IN (:custIds); 现在,我调用一个web服务,它返回一个ID列表。因此,我使用NamedParameterJdbcTemplate将ID列表映射到“custIds”。然而,当ID列表超过1000时,我遇到了一个问题。我已经读到DB将无法处理包含100或1000个以上的数据 由于我只能收到ID列表,除了NamedParame

我正在使用NamedParameterJdbcTemplate运行我的查询。查询如下:

SELECT id, desc FROM tableA WHERE id IN (:custIds);
现在,我调用一个web服务,它返回一个ID列表。因此,我使用NamedParameterJdbcTemplate将ID列表映射到“custIds”。然而,当ID列表超过1000时,我遇到了一个问题。我已经读到DB将无法处理包含100或1000个以上的数据


由于我只能收到ID列表,除了NamedParameterJdbcTemplate之外,您能建议最好使用什么吗?

子句中,您不能使用超过1000个条目。有以下几种解决方案:

  • 使用
    内部查询
    解决此问题。您可以创建一个临时表,并在
    in
    子句中使用它
示例查询:

select id,desc from table_name where id in (select id from temp_table)
select id,desc from table_name
  where
      id in (1,2,3,...1000)
  or
      id in (1001,1002,1003,...2000)
  or
      id in (2001,2002,...)
select id,desc from table_name where id in (1,2,3,4,...,1000)
union all
select id,desc from table_name where id in (1001,1002,...2000)
union all
select id,desc from table_name where id in (2001,2002,...)
子句中使用多个由或子句分隔的
,将其拆分为1000个条目

示例查询:

select id,desc from table_name where id in (select id from temp_table)
select id,desc from table_name
  where
      id in (1,2,3,...1000)
  or
      id in (1001,1002,1003,...2000)
  or
      id in (2001,2002,...)
select id,desc from table_name where id in (1,2,3,4,...,1000)
union all
select id,desc from table_name where id in (1001,1002,...2000)
union all
select id,desc from table_name where id in (2001,2002,...)
  • 或者使用
    union all
    代替上述
    子句,在
子句中的
中查询1000个条目

示例查询:

select id,desc from table_name where id in (select id from temp_table)
select id,desc from table_name
  where
      id in (1,2,3,...1000)
  or
      id in (1001,1002,1003,...2000)
  or
      id in (2001,2002,...)
select id,desc from table_name where id in (1,2,3,4,...,1000)
union all
select id,desc from table_name where id in (1001,1002,...2000)
union all
select id,desc from table_name where id in (2001,2002,...)

请参见

您在
子句中的
中不能使用超过1000个条目。有以下几种解决方案:

  • 使用
    内部查询
    解决此问题。您可以创建一个临时表,并在
    in
    子句中使用它
示例查询:

select id,desc from table_name where id in (select id from temp_table)
select id,desc from table_name
  where
      id in (1,2,3,...1000)
  or
      id in (1001,1002,1003,...2000)
  or
      id in (2001,2002,...)
select id,desc from table_name where id in (1,2,3,4,...,1000)
union all
select id,desc from table_name where id in (1001,1002,...2000)
union all
select id,desc from table_name where id in (2001,2002,...)
子句中使用多个由或子句分隔的
,将其拆分为1000个条目

示例查询:

select id,desc from table_name where id in (select id from temp_table)
select id,desc from table_name
  where
      id in (1,2,3,...1000)
  or
      id in (1001,1002,1003,...2000)
  or
      id in (2001,2002,...)
select id,desc from table_name where id in (1,2,3,4,...,1000)
union all
select id,desc from table_name where id in (1001,1002,...2000)
union all
select id,desc from table_name where id in (2001,2002,...)
  • 或者使用
    union all
    代替上述
    子句,在
子句中的
中查询1000个条目

示例查询:

select id,desc from table_name where id in (select id from temp_table)
select id,desc from table_name
  where
      id in (1,2,3,...1000)
  or
      id in (1001,1002,1003,...2000)
  or
      id in (2001,2002,...)
select id,desc from table_name where id in (1,2,3,4,...,1000)
union all
select id,desc from table_name where id in (1001,1002,...2000)
union all
select id,desc from table_name where id in (2001,2002,...)

请参见

如何创建一个带有ID的临时表并在查询中使用它?好的,我会试试。感谢我的经验限制…IN来自数据库,而不是SpringJDBC。看看你用的是什么数据库?是的,我也同意对数据库的限制。我正在使用Oracle。用ID创建一个临时表并在查询中使用它怎么样?好的,我试试看。感谢我的经验限制…IN来自数据库,而不是SpringJDBC。看看你用的是什么数据库?是的,我也同意对数据库的限制。我在用甲骨文。