ORACLE SQL语句in超过1000个的处理方法

  1. Iterator agitr = args.iterator();  
  2.          Set rst = new HashSet();  
  3.          Set rst1 = new HashSet();  
  4.         while (agitr.hasNext()) {  
  5.              String gpcode = (String) agitr.next();  
  6.             boolean isretain = true;  
  7.             if (grpusr_code != null && grpusr_code.length() > 0) {  
  8.                  isretain &= cdlist.contains(gpcode);  
  9.              }  
  10.             if (grpusr_name != null && grpusr_name.length() > 0) {  
  11.                  isretain &= nmlist.contains(gpcode);  
  12.              }  
  13.             if (citystr != null && citystr.length() > 0) {  
  14.                  isretain &= arlist.contains(gpcode);  
  15.              }  
  16.             if (propstr != null && propstr.length() > 0) {  
  17.                  isretain &= pplist.contains(gpcode);  
  18.              }  
  19.              isretain &= uslist.contains(gpcode);  
  20.             if (isretain) {  
  21.                 if (rst.size() <=800){  
  22.                      rst.add("'" + gpcode + "'");  
  23.                  }else{  
  24.                      rst1.add("'" + gpcode + "'");  
  25.                  }  
  26.                   
  27.              }  
  28.          }  
  29.          String cdstr = StringUtils.join(rst.iterator(), ",");  
  30.          String cdstr1 = StringUtils.join(rst1.iterator(),",");  
  31.         // 查询总积分  
  32.           
  33.         if (cdstr != null && cdstr.length() > 0) {  
  34.             if (cdstr1 !=null && cdstr1.length()>0){  
  35.                  String hql = "select tot_cash from TotalCashPromotionData as tot_cash where tot_cash.groupUserInfo.groupUserCode in ("  
  36.                      + cdstr + ") or tot_cash.groupUserInfo.groupUserCode in ("+cdstr1+")";  
  37.                 return this.paginatedDAO.getPaginatedList(hql, page, pageSize);  
  38.              }else{  
  39.                  String hql = "select tot_cash from TotalCashPromotionData as tot_cash where tot_cash.groupUserInfo.groupUserCode in ("  
  40.                      + cdstr + ")";  
  41.                 return this.paginatedDAO.getPaginatedList(hql, page, pageSize);  
  42.              }  
  43.               
  44.          } else {  
  45.              String hql = "select tot_cash from TotalCashPromotionData as tot_cash where tot_cash.groupUserInfo.groupUserCode in ('0')";  
  46.             return this.paginatedDAO.getPaginatedList(hql, page, pageSize);  
  47.          }  
原文地址:https://www.cnblogs.com/Snowolf/p/2186181.html