openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fa...@apache.org
Subject svn commit: r915725 - in /openjpa/trunk: openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/expressions/TestJPQLScalarExpressions.java
Date Wed, 24 Feb 2010 08:55:07 GMT
Author: fancy
Date: Wed Feb 24 08:55:07 2010
New Revision: 915725

URL: http://svn.apache.org/viewvc?rev=915725&view=rev
Log:
OPENJPA-1533: JPA2 select math mix with aggregate reports syntax error

Modified:
    openjpa/trunk/openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/expressions/TestJPQLScalarExpressions.java

Modified: openjpa/trunk/openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt?rev=915725&r1=915724&r2=915725&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt (original)
+++ openjpa/trunk/openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt Wed
Feb 24 08:55:07 2010
@@ -522,8 +522,8 @@
 
 void select_expression() #SELECTEXPRESSION : { }
 {
-	(LOOKAHEAD(aggregate_select_expression()) aggregate_select_expression()
-		| LOOKAHEAD(scalar_expression()) scalar_expression()
+	(LOOKAHEAD(scalar_expression()) scalar_expression()
+		| LOOKAHEAD(aggregate_select_expression()) aggregate_select_expression()
 		| LOOKAHEAD(path()) path()
 		| LOOKAHEAD(qualified_path()) qualified_path()
 		| LOOKAHEAD(qualified_identification_variable()) qualified_identification_variable()

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/expressions/TestJPQLScalarExpressions.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/expressions/TestJPQLScalarExpressions.java?rev=915725&r1=915724&r2=915725&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/expressions/TestJPQLScalarExpressions.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/expressions/TestJPQLScalarExpressions.java
Wed Feb 24 08:55:07 2010
@@ -70,6 +70,30 @@
     }
 
     @SuppressWarnings("unchecked")
+    public void testMathAndAggregate() {
+        EntityManager em = currentEntityManager();
+        String query[] = {
+            "SELECT SUM(c.age) + SUM(c.userid) FROM CompUser c",
+            "SELECT SUM(c.age) * SUM(c.userid) FROM CompUser c",
+            "SELECT SUM(c.age) - MIN(c.userid) + MAX(c.userid) FROM CompUser c",
+        };
+        for (int i = 0; i < query.length; i++) {
+            List<Long> rs = em.createQuery(query[i]).getResultList();
+            assertTrue(rs.get(0) > 0);
+        }
+        String query2[] = {
+                "SELECT SUM(c.age) + SUM(c.userid), MIN(c.age) + MAX(c.age) FROM CompUser
c",
+                "SELECT SUM(c.age) * SUM(c.userid), AVG(c.age) FROM CompUser c",
+                "SELECT SUM(c.age) - MIN(c.userid) + MAX(c.userid), AVG(c.age)/10 FROM CompUser
c",
+        };
+        for (int i = 0; i < query2.length; i++) {
+            List<Object[]> rs = (List<Object[]>)em.createQuery(query2[i]).getResultList();
+            assertNotNull(rs.get(0)[1]);
+        }
+        endEm(em);
+    }
+
+    @SuppressWarnings("unchecked")
     public void testCoalesceExpressions() {
         EntityManager em = currentEntityManager();
         startTx(em);



Mime
View raw message