cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r572137 - in /cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src: main/java/org/apache/cayenne/access/jdbc/ main/java/org/apache/cayenne/query/ test/java/org/apache/cayenne/access/
Date Sun, 02 Sep 2007 20:09:29 GMT
Author: aadamchik
Date: Sun Sep  2 13:09:29 2007
New Revision: 572137

URL: http://svn.apache.org/viewvc?rev=572137&view=rev
Log:
adding fetch limit support to EJBQL query

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLAction.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQuery.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/query/SelectQuery.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLQueryTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLAction.java?rev=572137&r1=572136&r2=572137&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLAction.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLAction.java
Sun Sep  2 13:09:29 2007
@@ -29,6 +29,7 @@
 import org.apache.cayenne.ejbql.EJBQLExpressionVisitor;
 import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.query.EJBQLQuery;
+import org.apache.cayenne.query.QueryMetadata;
 import org.apache.cayenne.query.SQLActionVisitor;
 import org.apache.cayenne.query.SQLTemplate;
 
@@ -87,6 +88,11 @@
         });
 
         SQLTemplate sqlQuery = context.getQuery();
+
+        // update with metadata
+        QueryMetadata md = query.getMetaData(getEntityResolver());
+        sqlQuery.setFetchLimit(md.getFetchLimit());
+
         actionFactory.sqlAction(sqlQuery).performAction(connection, observer);
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQuery.java?rev=572137&r1=572136&r2=572137&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQuery.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQuery.java
Sun Sep  2 13:09:29 2007
@@ -147,4 +147,20 @@
 
         parameters.put(new Integer(position), object);
     }
+
+    /**
+     * Returns the fetchLimit property indicating the maximum number of rows this query
+     * would return.
+     */
+    public int getFetchLimit() {
+        return metadata.getFetchLimit();
+    }
+
+    /**
+     * Sets the fetchLimit property indicating the maximum number of rows this query would
+     * return.
+     */
+    public void setFetchLimit(int fetchLimit) {
+        this.metadata.setFetchLimit(fetchLimit);
+    }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/query/SelectQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/query/SelectQuery.java?rev=572137&r1=572136&r2=572137&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/query/SelectQuery.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/query/SelectQuery.java
Sun Sep  2 13:09:29 2007
@@ -580,8 +580,6 @@
 
     /**
      * Returns the fetchLimit.
-     * 
-     * @return int
      */
     public int getFetchLimit() {
         return selectInfo.getFetchLimit();
@@ -589,8 +587,6 @@
 
     /**
      * Sets the fetchLimit.
-     * 
-     * @param fetchLimit The fetchLimit to set
      */
     public void setFetchLimit(int fetchLimit) {
         this.selectInfo.setFetchLimit(fetchLimit);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLQueryTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLQueryTest.java?rev=572137&r1=572136&r2=572137&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLQueryTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLQueryTest.java
Sun Sep  2 13:09:29 2007
@@ -125,6 +125,17 @@
         assertTrue(artists.get(0) instanceof Artist);
         assertTrue(((Artist) artists.get(0)).getPersistenceState() == PersistenceState.COMMITTED);
     }
+    
+    public void testFetchLimit() throws Exception {
+        createTestData("prepare");
+
+        String ejbql = "select a FROM Artist a";
+        EJBQLQuery query = new EJBQLQuery(ejbql);
+        query.setFetchLimit(2);
+
+        List artists = createDataContext().performQuery(query);
+        assertEquals(2, artists.size());
+    }
 
     public void testSelectFromWhereEqual() throws Exception {
         createTestData("prepare");



Mime
View raw message