英文:
The incoming request has too many parameters
问题
我在使用 Hibernate 执行 SELECT
查询时遇到了以下异常:SQLServerException: 入站请求的参数过多。服务器支持最多 2100 个参数。请减少参数数量并重新发送请求。
。以下是我的查询语句:。
有人知道在 Hibernate 中有解决这个问题的方法吗?
非常感谢任何帮助,谢谢!
英文:
I have the following exception SQLServerException: The incoming request has too many parameters. The server supports a maximum of 2100 parameters. Reduce the number of parameters and resend the request.
while executing SELECT
query via Hibernate.
Here is my query
Does anybody know any solutions for this in Hibernate?
Will be very grateful for any help, thank you!
答案1
得分: 1
作为对这个问题的解决方法,可以将数据分块获取。
List<List<Long>> partitions = new ArrayList<List<Long>>();
List<Long> bucket = new ArrayList<>();
int count = 0;
for (Long id : ids) {
count++;
if (count > 1000) {
count = 1;
partitions.add(bucket);
bucket = new ArrayList<>();
}
partitions.add(bucket);
}
List<PreStagePaymentData> data = new ArrayList<>();
List<PreStagePaymentData> temp;
for (List<Long> partition : partitions) {
temp = findPreStageDataByPaymentIds(partition);
data.addAll(temp);
}
英文:
As a workaround for this issue would be to get data in chunks.
List<List<Long>> partitions = new ArrayList<List<Long>>();
List<Long> bucket = new ArrayList<>();
int count = 0;
for(Long id : ids){
count++;
if(count>1000){
count = 1;
partitions.add(bucket);
bucket = new ArrayList<>();
}
partitions.add(bucket);
}
List<PreStagePaymentData> data= new ArrayList<>();
List<PreStagePaymentData> temp;
for(List<Long> partition : partitions){
temp = findPreStageDataByPaymentIds(partition);
data.addAll(temp);
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论