cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r709924 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres: PostgresActionBuilder.java PostgresSelectAction.java PostgresSelectTranslator.java
Date Sun, 02 Nov 2008 20:55:11 GMT
Author: aadamchik
Date: Sun Nov  2 12:55:10 2008
New Revision: 709924

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

 switching PostgreSQL to the new lifecycle method for LIMIT/OFFSET

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresActionBuilder.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresSelectAction.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresSelectTranslator.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresActionBuilder.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresActionBuilder.java?rev=709924&r1=709923&r2=709924&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresActionBuilder.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresActionBuilder.java
Sun Nov  2 12:55:10 2008
@@ -19,9 +19,6 @@
 
 package org.apache.cayenne.dba.postgres;
 
-import java.sql.Connection;
-
-import org.apache.cayenne.access.trans.SelectTranslator;
 import org.apache.cayenne.dba.JdbcActionBuilder;
 import org.apache.cayenne.dba.JdbcAdapter;
 import org.apache.cayenne.map.EntityResolver;
@@ -46,17 +43,6 @@
 
     @Override
     public SQLAction objectSelectAction(SelectQuery query) {
-        return new PostgresSelectAction(query, adapter, entityResolver) {
-
-            @Override
-            protected SelectTranslator createTranslator(Connection connection) {
-                SelectTranslator translator = new PostgresSelectTranslator();
-                translator.setQuery(query);
-                translator.setAdapter(adapter);
-                translator.setEntityResolver(getEntityResolver());
-                translator.setConnection(connection);
-                return translator;
-            }
-        };
+        return new PostgresSelectAction(query, adapter, entityResolver);
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresSelectAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresSelectAction.java?rev=709924&r1=709923&r2=709924&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresSelectAction.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresSelectAction.java
Sun Nov  2 12:55:10 2008
@@ -18,7 +18,10 @@
  ****************************************************************/
 package org.apache.cayenne.dba.postgres;
 
+import java.sql.Connection;
+
 import org.apache.cayenne.access.jdbc.SelectAction;
+import org.apache.cayenne.access.trans.SelectTranslator;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.query.SelectQuery;
@@ -37,4 +40,14 @@
     protected int getInitialCursorPosition(int queryOffset) {
         return 0;
     }
+
+    @Override
+    protected SelectTranslator createTranslator(Connection connection) {
+        SelectTranslator translator = new PostgresSelectTranslator();
+        translator.setQuery(query);
+        translator.setAdapter(adapter);
+        translator.setEntityResolver(getEntityResolver());
+        translator.setConnection(connection);
+        return translator;
+    }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresSelectTranslator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresSelectTranslator.java?rev=709924&r1=709923&r2=709924&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresSelectTranslator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresSelectTranslator.java
Sun Nov  2 12:55:10 2008
@@ -26,27 +26,23 @@
  * @since 1.2
  * @author Andrus Adamchik
  */
-public class PostgresSelectTranslator extends SelectTranslator {
+class PostgresSelectTranslator extends SelectTranslator {
 
     @Override
-    public String createSqlString() throws Exception {
-        String sql = super.createSqlString();
+    protected void appendLimitAndOffsetClauses(StringBuilder buffer) {
+        QueryMetadata metadata = getQuery().getMetaData(getEntityResolver());
 
-        if (!isSuppressingDistinct()) {
-            QueryMetadata metadata = getQuery().getMetaData(getEntityResolver());
+        // limit results
+        int offset = metadata.getFetchOffset();
+        int limit = metadata.getFetchLimit();
 
-            // limit results
-            int offset = metadata.getFetchOffset();
-            int limit = metadata.getFetchLimit();
-
-            if (limit > 0) {
-                sql += " LIMIT " + limit;
-            }
+        if (limit > 0) {
+            buffer.append(" LIMIT ").append(limit);
+        }
 
-            if (offset > 0) {
-                sql += " OFFSET " + offset;
-            }
+        if (offset > 0) {
+            buffer.append(" OFFSET ").append(offset);
         }
-        return sql;
     }
+
 }



Mime
View raw message