openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fa...@apache.org
Subject svn commit: r764668 - in /openjpa/trunk: openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/m2mmapex0/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa...
Date Tue, 14 Apr 2009 04:09:06 GMT
Author: fancy
Date: Tue Apr 14 04:09:05 2009
New Revision: 764668

URL: http://svn.apache.org/viewvc?rev=764668&view=rev
Log:
OPENJPA-1035 JPA2 Query allow map key/value path to appear as argument to scalar functions

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/jdbc/maps/m2mmapex0/TestMany2ManyMap.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/m2mmapex10/TestMany2ManyMapEx10.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=764668&r1=764667&r2=764668&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 Tue
Apr 14 04:09:05 2009
@@ -945,11 +945,11 @@
 	LOOKAHEAD(path()) path() |
 	LOOKAHEAD(qualified_path()) qualified_path() |
 	LOOKAHEAD(general_identification_variable()) general_identification_variable() |
-	LOOKAHEAD(2) "(" arithmetic_expression() ")" | 
-	functions_returning_numerics() | 
-	aggregate_select_expression() |	
+	LOOKAHEAD("("  arithmetic_expression()) "("  arithmetic_expression() ")" | 
+	LOOKAHEAD(functions_returning_numerics()) functions_returning_numerics() | 
+	LOOKAHEAD(aggregate_select_expression()) aggregate_select_expression() |	
 	LOOKAHEAD(case_expression()) case_expression() |
-	"(" subquery() ")"
+	LOOKAHEAD("(" subquery()) "(" subquery() ")"
 }
 
 
@@ -1081,9 +1081,10 @@
 void string_primary() : { }
 {
 	string_literal() | path() |
-	LOOKAHEAD(general_identification_variable()) general_identification_variable() |	
-	LOOKAHEAD(2) "(" string_expression() ")" | 
-	functions_returning_strings() | LOOKAHEAD(2)  "(" subquery() ")"
+	LOOKAHEAD(qualified_path()) qualified_path() |	
+	LOOKAHEAD(general_identification_variable()) general_identification_variable() |
+	LOOKAHEAD("(" string_expression()) "(" string_expression() ")" | 
+	functions_returning_strings() | LOOKAHEAD("(" subquery()) "(" subquery() ")"
 	| case_expression()
 }
 
@@ -1097,6 +1098,7 @@
 void datetime_primary() : { }
 {
 	path() | functions_returning_datetime() | input_parameter() | aggregate_select_expression()
+	| LOOKAHEAD(qualified_path()) qualified_path()
 	| LOOKAHEAD(general_identification_variable()) general_identification_variable()
 	| case_expression()
 }
@@ -1117,6 +1119,8 @@
 void boolean_primary() : { }
 {
 	LOOKAHEAD(2) path() | boolean_literal() | input_parameter()
+	| LOOKAHEAD(qualified_path()) qualified_path()
+	| LOOKAHEAD(general_identification_variable()) general_identification_variable()
 	| case_expression()
 }
 
@@ -1132,6 +1136,8 @@
 	LOOKAHEAD(2) path()
 	| LOOKAHEAD(enum_literal()) enum_literal()
 	| LOOKAHEAD(input_parameter()) input_parameter()
+	| LOOKAHEAD(qualified_path()) qualified_path()
+	| LOOKAHEAD(general_identification_variable()) general_identification_variable()
 	| case_expression()
 }
 

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/m2mmapex0/TestMany2ManyMap.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/m2mmapex0/TestMany2ManyMap.java?rev=764668&r1=764667&r2=764668&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/m2mmapex0/TestMany2ManyMap.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/m2mmapex0/TestMany2ManyMap.java
Tue Apr 14 04:09:05 2009
@@ -142,7 +142,7 @@
         // expects parser error:
         // JPA2 has no support for predicate comparison using
         // Key(e) or Value(e)
-        String query1 = "select KEY(p) from Employee e, " +
+        query = "select KEY(p) from Employee e, " +
             " in (e.phones) p where KEY(p) = ?1";
         try {
             q = em.createQuery(query).setParameter(1, d2);
@@ -160,6 +160,18 @@
         if (inMemory) 
             setCandidate(q, Employee.class);
         rs = q.getResultList();
+        assertEquals(0, rs.size());
+
+        // test qualified path in scalar functions
+        query = "select CONCAT(KEY(p).name, 'xyz') from Employee e, " +
+            " in (e.phones) p WHERE SUBSTRING(KEY(p).name, 1)" +
+            " like '%2'";
+        q = em.createQuery(query);
+        if (inMemory) 
+            setCandidate(q, Employee.class);
+        rs = q.getResultList();
+        assertEquals(((String) rs.get(0)), "d2xyz");
+
         em.close();
     }
 

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/m2mmapex10/TestMany2ManyMapEx10.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/m2mmapex10/TestMany2ManyMapEx10.java?rev=764668&r1=764667&r2=764668&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/m2mmapex10/TestMany2ManyMapEx10.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/m2mmapex10/TestMany2ManyMapEx10.java
Tue Apr 14 04:09:05 2009
@@ -155,6 +155,14 @@
         rs = q.getResultList();
         if (!inMemory)
         assertTrue(sql.get(0).toUpperCase().indexOf(" GROUP BY ") != -1);
+        
+        query = "select LENGTH(KEY(e).name) from PhoneNumber p, " +
+            " in (p.emps) e where KEY(e).bDay = CURRENT_TIMESTAMP";
+        q = em.createQuery(query);
+        if (inMemory) 
+            setCandidate(q, Employee.class);
+        rs = q.getResultList();
+        assertEquals(rs.size(), 0);
 
         em.close();
     }



Mime
View raw message