The overridden toSelect() signature in the OracleDictionary was no longer appropriate since the DBDictionary.toSelect() change in revision #577972 (which fixed OPENJPA-378). This resulted in the special Oracle range handing to no longer take place, resulting in setFirstResult() and setMaxResults() effectively being ignored for Oracle.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@584463 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Marc Prud'hommeaux 2007-10-14 01:02:19 +00:00
parent eb6a63c2c7
commit 5b67b240f1
1 changed files with 10 additions and 7 deletions

View File

@ -45,6 +45,7 @@ import org.apache.openjpa.jdbc.schema.Index;
import org.apache.openjpa.jdbc.schema.PrimaryKey;
import org.apache.openjpa.jdbc.schema.Sequence;
import org.apache.openjpa.jdbc.schema.Table;
import org.apache.openjpa.jdbc.sql.Select;
import org.apache.openjpa.lib.jdbc.DelegatingDatabaseMetaData;
import org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement;
import org.apache.openjpa.lib.util.Localizer;
@ -353,7 +354,8 @@ public class OracleDictionary
public SQLBuffer toSelect(SQLBuffer select, JDBCFetchConfiguration fetch,
SQLBuffer tables, SQLBuffer where, SQLBuffer group,
SQLBuffer having, SQLBuffer order,
boolean distinct, boolean forUpdate, long start, long end) {
boolean distinct, boolean forUpdate, long start, long end,
Select sel) {
if (!_checkedUpdateBug) {
ensureDriverVendor();
if (forUpdate && _driverBehavior == BEHAVE_DATADIRECT31)
@ -364,7 +366,7 @@ public class OracleDictionary
// if no range, use standard select
if (start == 0 && end == Long.MAX_VALUE)
return super.toSelect(select, fetch, tables, where, group, having,
order, distinct, forUpdate, 0, Long.MAX_VALUE);
order, distinct, forUpdate, 0, Long.MAX_VALUE, sel);
// if no skip, ordering, or distinct can use rownum directly
SQLBuffer buf = new SQLBuffer(this);
@ -373,17 +375,18 @@ public class OracleDictionary
buf.append(where).append(" AND ");
buf.append("ROWNUM <= ").appendValue(end);
return super.toSelect(select, fetch, tables, buf, group, having,
order, distinct, forUpdate, 0, Long.MAX_VALUE);
order, distinct, forUpdate, 0, Long.MAX_VALUE, sel);
}
// if there is ordering, skip, or distinct we have to use subselects
SQLBuffer sel = super.toSelect(select, fetch, tables, where,
group, having, order, distinct, forUpdate, 0, Long.MAX_VALUE);
SQLBuffer newsel = super.toSelect(select, fetch, tables, where,
group, having, order, distinct, forUpdate, 0, Long.MAX_VALUE,
sel);
// if no skip, can use single nested subselect
if (start == 0) {
buf.append(getSelectOperation(fetch) + " * FROM (");
buf.append(sel);
buf.append(newsel);
buf.append(") WHERE ROWNUM <= ").appendValue(end);
return buf;
}
@ -392,7 +395,7 @@ public class OracleDictionary
// where conditions on the rownum
buf.append(getSelectOperation(fetch)
+ " * FROM (SELECT r.*, ROWNUM RNUM FROM (");
buf.append(sel);
buf.append(newsel);
buf.append(") r");
if (end != Long.MAX_VALUE)
buf.append(" WHERE ROWNUM <= ").appendValue(end);