cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r562872 - in /cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src: main/java/org/apache/cayenne/access/jdbc/EJBQLConditionTranslator.java test/java/org/apache/cayenne/access/DataContextEJBQLSubqueryTest.java
Date Sun, 05 Aug 2007 14:22:51 GMT
Author: aadamchik
Date: Sun Aug  5 07:22:50 2007
New Revision: 562872

URL: http://svn.apache.org/viewvc?view=rev&rev=562872
Log:
CAY-840 EJBQL Subquery support
(ANY/SOME subselect)

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLConditionTranslator.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLSubqueryTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLConditionTranslator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLConditionTranslator.java?view=diff&rev=562872&r1=562871&r2=562872
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLConditionTranslator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLConditionTranslator.java
Sun Aug  5 07:22:50 2007
@@ -87,6 +87,11 @@
         context.append(" ALL");
         return true;
     }
+    
+    public boolean visitAny(EJBQLExpression expression) {
+        context.append(" ANY");
+        return true;
+    }
 
     public boolean visitOr(EJBQLExpression expression, int finishedChildIndex) {
         afterChild(expression, " OR", finishedChildIndex);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLSubqueryTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLSubqueryTest.java?view=diff&rev=562872&r1=562871&r2=562872
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLSubqueryTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLSubqueryTest.java
Sun Aug  5 07:22:50 2007
@@ -82,4 +82,54 @@
         assertTrue(ids.contains(new Integer(33003)));
         assertTrue(ids.contains(new Integer(33004)));
     }
+    
+    public void testAny() throws Exception {
+        createTestData("prepare");
+
+        String ejbql = "SELECT p FROM Painting p"
+                + " WHERE p.estimatedPrice > ANY ("
+                + " SELECT p1.estimatedPrice FROM Painting p1"
+                + " WHERE p1.paintingTitle = 'P1'"
+                + ")";
+
+        EJBQLQuery query = new EJBQLQuery(ejbql);
+        List objects = createDataContext().performQuery(query);
+        assertEquals(3, objects.size());
+
+        Set ids = new HashSet();
+        Iterator it = objects.iterator();
+        while (it.hasNext()) {
+            Object id = DataObjectUtils.pkForObject((Persistent) it.next());
+            ids.add(id);
+        }
+
+        assertTrue(ids.contains(new Integer(33002)));
+        assertTrue(ids.contains(new Integer(33003)));
+        assertTrue(ids.contains(new Integer(33004)));
+    }
+    
+    public void testSome() throws Exception {
+        createTestData("prepare");
+
+        String ejbql = "SELECT p FROM Painting p"
+                + " WHERE p.estimatedPrice > SOME ("
+                + " SELECT p1.estimatedPrice FROM Painting p1"
+                + " WHERE p1.paintingTitle = 'P1'"
+                + ")";
+
+        EJBQLQuery query = new EJBQLQuery(ejbql);
+        List objects = createDataContext().performQuery(query);
+        assertEquals(3, objects.size());
+
+        Set ids = new HashSet();
+        Iterator it = objects.iterator();
+        while (it.hasNext()) {
+            Object id = DataObjectUtils.pkForObject((Persistent) it.next());
+            ids.add(id);
+        }
+
+        assertTrue(ids.contains(new Integer(33002)));
+        assertTrue(ids.contains(new Integer(33003)));
+        assertTrue(ids.contains(new Integer(33004)));
+    }
 }



Mime
View raw message