/**
* 目的就是为了处理Oracle in 超过1000条报错的问题 renjingkai
* @param ids
* @param count
* @return
*/
private String getOracleSQLIn(List<?> ids, int count) {
count = Math.min(count, 1000);
int len = ids.size();
int size = len % count;
if (size == 0) {
size = len / count;
} else {
size = (len / count) + 1;
}
StringBuilder builder = new StringBuilder();
for (int i = 0; i < size; i++) {
int fromIndex = i * count;
int toIndex = Math.min(fromIndex + count, len);
String productId = StringUtils.defaultIfEmpty(StringUtils.join(ids.subList(fromIndex, toIndex), "','"), "");
if (i != 0) {
builder.append(" and ");
}
builder.append(" ('").append(productId).append("')");
}
return StringUtils.defaultIfEmpty(builder.toString(), " ('') ");
}
将数据 ids 变为list当做参数传进去这个方法,count参数指的是根据count的值进行分割,最后返回 : (‘’,‘’,‘’)