The project framework can implement the query by splicing sql. When using the in function, if the field exceeds 1000, an error will be reported, so change it to (in or in) to implement the query
if(enterpriseCodeList.size()>900)
{
sql2 += " and (";
int j = enterpriseCodeList.size()/900;
int k = enterpriseCodeList.size()%900;
if(k>0)
{
j = j+1;}for(int i = 1;i <= j;i++){List<String> enterpriseCodeSqlList = new ArrayList<String>();int x = 900*(i-1);int y = 0;if(i==j){y = enterpriseCodeList.size();sql2 += ("t.enterpriseCode in (:enterpriseCodeList"+i+"))");}else{y = 900*i;sql2 += ("t.enterpriseCode in (:enterpriseCodeList"+i+") or ");}
// 集合截取,左闭右开
enterpriseCodeSqlList = enterpriseCodeList.subList(x, y);
map2.put("enterpriseCodeList"+i, enterpriseCodeSqlList);
}
}
else
{
sql2 += " and t.enterpriseCode in (:enterpriseCodeList) ";
map2.put("enterpriseCodeList", enterpriseCodeList);
}
At this time, I encountered an AST node: {vector} error when testing, and I solved it by adding the brackets marked in red in the previous code.