cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r709928 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleSelectTranslator.java
Date Sun, 02 Nov 2008 20:58:18 GMT
Author: aadamchik
Date: Sun Nov  2 12:58:18 2008
New Revision: 709928

URL: http://svn.apache.org/viewvc?rev=709928&view=rev
Log:
Add LIMIT / OFFSET clause generation method to SelectTranslator lifecycle

 switching Oracle to the new lifecycle method for LIMIT/OFFSET

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleSelectTranslator.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleSelectTranslator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleSelectTranslator.java?rev=709928&r1=709927&r2=709928&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleSelectTranslator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleSelectTranslator.java
Sun Nov  2 12:58:18 2008
@@ -30,33 +30,24 @@
  * 
  * @author Andrus Adamchik
  */
-public class OracleSelectTranslator extends SelectTranslator {
+class OracleSelectTranslator extends SelectTranslator {
 
     @Override
-    public String createSqlString() throws Exception {
-
-        String sqlString = super.createSqlString();
-
-        if (!isSuppressingDistinct()) {
-            QueryMetadata info = getQuery().getMetaData(getEntityResolver());
-            if (info.getFetchLimit() > 0 || info.getFetchOffset() > 0) {
-                int max = (info.getFetchLimit() == 0) ? Integer.MAX_VALUE : (info
-                        .getFetchLimit() + info.getFetchOffset());
-
-                sqlString = "select * "
-                        + "from ( select "
-                        + "tid.*, ROWNUM rnum "
-                        + "from ("
-                        + sqlString
-                        + ") tid "
-                        + "where ROWNUM <="
-                        + max
-                        + ") where rnum  > "
-                        + info.getFetchOffset();
-            }
+    protected void appendLimitAndOffsetClauses(StringBuilder buffer) {
+        QueryMetadata metadata = getQuery().getMetaData(getEntityResolver());
+        int offset = metadata.getFetchOffset();
+        int limit = metadata.getFetchLimit();
+
+        if (limit > 0 || offset > 0) {
+            int max = (limit <= 0) ? Integer.MAX_VALUE : limit + offset;
+
+            buffer.insert(0, "select * from ( select tid.*, ROWNUM rnum from (");
+            buffer
+                    .append(") tid where ROWNUM <=")
+                    .append(max)
+                    .append(") where rnum  > ")
+                    .append(offset);
         }
-
-        return sqlString;
     }
 
     /**



Mime
View raw message