cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r725609 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/query/EJBQLQuery.java test/java/org/apache/cayenne/query/EJBQLQueryTest.java
Date Thu, 11 Dec 2008 07:36:44 GMT
Author: aadamchik
Date: Wed Dec 10 23:36:43 2008
New Revision: 725609

URL: http://svn.apache.org/viewvc?rev=725609&view=rev
Log:
CAY-1047 Aligning query capabilities

patch to support DataRows in the EJBQLQuery by Dima Loiko

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQuery.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/EJBQLQueryTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQuery.java?rev=725609&r1=725608&r2=725609&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQuery.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQuery.java
Wed Dec 10 23:36:43 2008
@@ -52,6 +52,14 @@
         return metadata;
     }
 
+    public boolean isFetchingDataRows() {
+        return metadata.isFetchingDataRows();
+    }
+
+    public void setFetchingDataRows(boolean flag) {
+        metadata.setFetchingDataRows(flag);
+    }
+
     public void route(QueryRouter router, EntityResolver resolver, Query substitutedQuery)
{
         DataMap map = getMetaData(resolver).getDataMap();
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/EJBQLQueryTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/EJBQLQueryTest.java?rev=725609&r1=725608&r2=725609&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/EJBQLQueryTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/EJBQLQueryTest.java
Wed Dec 10 23:36:43 2008
@@ -18,8 +18,12 @@
  ****************************************************************/
 package org.apache.cayenne.query;
 
+import java.util.List;
 import java.util.Map;
 
+import org.apache.art.Artist;
+import org.apache.cayenne.DataRow;
+import org.apache.cayenne.access.DataContext;
 import org.apache.cayenne.ejbql.EJBQLCompiledExpression;
 import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.unit.CayenneCase;
@@ -38,6 +42,34 @@
         assertEquals("Y", parameters.get("name"));
     }
 
+    public void testDataRows() {
+        insertValue();
+        String ejbql = "select a FROM Artist a";
+        EJBQLQuery query = new EJBQLQuery(ejbql);
+        query.setFetchingDataRows(true);
+        List artists = createDataContext().performQuery(query);
+
+        Map row = (Map) artists.get(0);
+        assertTrue(row instanceof DataRow);
+
+        Artist artist = (Artist) createDataContext().objectFromDataRow(
+                "Artist",
+                (DataRow) row,
+                true);
+        assertEquals("a0", artist.getArtistName());
+
+    }
+
+    private void insertValue() {
+        DataContext context = createDataContext();
+
+        for (int i = 0; i < 5; i++) {
+            Artist obj = context.newObject(Artist.class);
+            obj.setArtistName("a" + i);
+            context.commitChanges();
+        }
+    }
+
     public void testGetExpression() {
         String ejbql = "select a FROM Artist a";
         EJBQLQuery query = new EJBQLQuery(ejbql);



Mime
View raw message