cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From and...@apache.org
Subject svn commit: r918469 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/access/jdbc/ test/java/org/apache/cayenne/access/
Date Wed, 03 Mar 2010 13:41:09 GMT
Author: andrey
Date: Wed Mar  3 13:41:08 2010
New Revision: 918469

URL: http://svn.apache.org/viewvc?rev=918469&view=rev
Log:
CAY-1376 Certain EJBQL queries have mismatched table aliases.

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLGroupByTranslator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLPathTranslator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLGroupByHavingTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLGroupByTranslator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLGroupByTranslator.java?rev=918469&r1=918468&r2=918469&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLGroupByTranslator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLGroupByTranslator.java
Wed Mar  3 13:41:08 2010
@@ -73,13 +73,14 @@
             @Override
             public boolean visitIdentificationVariable(EJBQLExpression expression) {
 
-                String idVariableAbsolutePath = idPath+"."+expression.getText();
+                String idVariableAbsolutePath = fullPath + "." + expression.getText();
                 ClassDescriptor descriptor = context.getEntityDescriptor(idVariableAbsolutePath);
                 if (descriptor != null) {
                     this.lastAlias = context.getTableAlias(idVariableAbsolutePath, descriptor.getEntity().getDbEntity().getFullyQualifiedName());
                 }
 
                 this.lastPathComponent = expression.getText();
+                this.fullPath = fullPath + '.' + lastPathComponent;
                 
                 return true;
             }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLPathTranslator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLPathTranslator.java?rev=918469&r1=918468&r2=918469&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLPathTranslator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLPathTranslator.java
Wed Mar  3 13:41:08 2010
@@ -50,7 +50,7 @@
     protected String lastAlias;
     protected String idPath;
     protected String joinMarker;
-    private String fullPath;
+    protected String fullPath;
     private boolean usingAliases;
 
     public EJBQLPathTranslator(EJBQLTranslationContext context) {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLGroupByHavingTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLGroupByHavingTest.java?rev=918469&r1=918468&r2=918469&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLGroupByHavingTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLGroupByHavingTest.java
Wed Mar  3 13:41:08 2010
@@ -239,5 +239,19 @@
             assertFalse(expectedResults.add(Arrays.asList(row[0], row[1])));
         }
     }
+
+    public void testGroupByChainedJoins() throws Exception {
+        createTestData("prepare");
+
+        String ejbql = "SELECT p.painting.toArtist.paintingArray FROM PaintingInfo p"
+                + " GROUP BY p.painting.toArtist.paintingArray";
+        EJBQLQuery query = new EJBQLQuery(ejbql);
+        List data = createDataContext().performQuery(query);
+        
+        ejbql = "SELECT p.painting.toArtist FROM PaintingInfo p"
+            + " GROUP BY p.painting.toArtist";
+        query = new EJBQLQuery(ejbql);
+        createDataContext().performQuery(query);
+    }
     
 }



Mime
View raw message