From 5b67b240f1d53eae36fba27611c501003cf700a7 Mon Sep 17 00:00:00 2001 From: Marc Prud'hommeaux Date: Sun, 14 Oct 2007 01:02:19 +0000 Subject: [PATCH] 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 --- .../openjpa/jdbc/sql/OracleDictionary.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java index 65599de6b..bca60f843 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java @@ -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);