mirror of https://github.com/apache/openjpa.git
Simplify breaking up long IN clauses into multiple OR'd IN clauses based on the
dictionary's IN clause limit git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@522600 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
442c1cee48
commit
9b61ded11b
|
@ -392,22 +392,16 @@ public class PagingResultObjectProvider
|
||||||
private void createInContains(Select sel, DBDictionary dict, SQLBuffer buf,
|
private void createInContains(Select sel, DBDictionary dict, SQLBuffer buf,
|
||||||
ClassMapping mapping, Column[] pks, int start, int end) {
|
ClassMapping mapping, Column[] pks, int start, int end) {
|
||||||
int inClauseLimit = dict.inClauseLimit;
|
int inClauseLimit = dict.inClauseLimit;
|
||||||
if ((inClauseLimit == -1) || ((end - start) <= inClauseLimit))
|
if (inClauseLimit <= 0 || end - start <= inClauseLimit)
|
||||||
inContains(sel, buf, mapping, pks, start, end);
|
inContains(sel, buf, mapping, pks, start, end);
|
||||||
else {
|
else {
|
||||||
buf.append("(");
|
buf.append("(");
|
||||||
|
for (int low = start, high; low < end; low = high) {
|
||||||
int low = start;
|
if (low > start)
|
||||||
for (int i = 1, stop = (end - start)/inClauseLimit; i <= stop; i++) {
|
|
||||||
inContains(sel, buf, mapping, pks, low, low + inClauseLimit);
|
|
||||||
low += inClauseLimit;
|
|
||||||
if (low < end)
|
|
||||||
buf.append(" OR ");
|
buf.append(" OR ");
|
||||||
|
high = Math.min(low + inClauseLimit, end);
|
||||||
|
inContains(sel, buf, mapping, pks, low, high);
|
||||||
}
|
}
|
||||||
// Remaining
|
|
||||||
if (low < end)
|
|
||||||
inContains(sel, buf, mapping, pks, low, end);
|
|
||||||
|
|
||||||
buf.append(")");
|
buf.append(")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,25 +123,16 @@ class InExpression
|
||||||
SQLBuffer buf, List list, Column[] cols) {
|
SQLBuffer buf, List list, Column[] cols) {
|
||||||
|
|
||||||
int inClauseLimit = ctx.store.getDBDictionary().inClauseLimit;
|
int inClauseLimit = ctx.store.getDBDictionary().inClauseLimit;
|
||||||
if ((inClauseLimit == -1) || (list.size() < inClauseLimit))
|
if (inClauseLimit <= 0 || list.size() <= inClauseLimit)
|
||||||
inContains(sel, ctx, state, buf, list, cols);
|
inContains(sel, ctx, state, buf, list, cols);
|
||||||
else {
|
else {
|
||||||
buf.append("(");
|
buf.append("(");
|
||||||
|
for (int low = 0, high; low < list.size(); low = high) {
|
||||||
int low = 0;
|
if (low > 0)
|
||||||
for (int i = 1, stop = list.size()/inClauseLimit; i <= stop; i++) {
|
|
||||||
List subList = list.subList(low, low + inClauseLimit);
|
|
||||||
inContains(sel, ctx, state, buf, subList, cols);
|
|
||||||
low += inClauseLimit;
|
|
||||||
if (low < list.size())
|
|
||||||
buf.append(" OR ");
|
buf.append(" OR ");
|
||||||
|
high = java.lang.Math.min(low + inClauseLimit, list.size());
|
||||||
|
inContains(sel, ctx, state, buf, list.subList(low, high), cols);
|
||||||
}
|
}
|
||||||
// Remaining
|
|
||||||
if (low < list.size()) {
|
|
||||||
List rem = list.subList(low, list.size());
|
|
||||||
inContains(sel, ctx, state, buf, rem, cols);
|
|
||||||
}
|
|
||||||
|
|
||||||
buf.append(")");
|
buf.append(")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue