cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r609391 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/ejbql/ main/java/org/apache/cayenne/ejbql/parser/ main/java/org/apache/cayenne/exp/parser/ main/jjtree/org/apache/cayenne/ejbql/ test/ja...
Date Sun, 06 Jan 2008 20:06:27 GMT
Author: aadamchik
Date: Sun Jan  6 12:06:25 2008
New Revision: 609391

URL: http://svn.apache.org/viewvc?rev=609391&view=rev
Log:
CAY-954 EJBQL Query: Support for single table inheritance
(support for dbpath in EJBQL syntax, so that traditional Cayenne expressions could be converted
to EJBQL)

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLDbPath.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/ejbql/EJBQLExpressionTest.java
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ejbql/EJBQLBaseVisitor.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ejbql/EJBQLExpressionVisitor.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTDbPath.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/jjtree/org/apache/cayenne/ejbql/EJBQLParser.jjt

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ejbql/EJBQLBaseVisitor.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ejbql/EJBQLBaseVisitor.java?rev=609391&r1=609390&r2=609391&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ejbql/EJBQLBaseVisitor.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ejbql/EJBQLBaseVisitor.java
Sun Jan  6 12:06:25 2008
@@ -133,6 +133,10 @@
     public boolean visitDescending(EJBQLExpression expression) {
         return continueFlag;
     }
+    
+    public boolean visitDbPath(EJBQLExpression expression) {
+        return continueFlag;
+    }
 
     public boolean visitDistinct(EJBQLExpression expression) {
         return continueFlag;

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ejbql/EJBQLExpressionVisitor.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ejbql/EJBQLExpressionVisitor.java?rev=609391&r1=609390&r2=609391&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ejbql/EJBQLExpressionVisitor.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ejbql/EJBQLExpressionVisitor.java
Sun Jan  6 12:06:25 2008
@@ -274,6 +274,8 @@
      *            visited.
      */
     boolean visitPath(EJBQLExpression expression, int finishedChildIndex);
+    
+    boolean visitDbPath(EJBQLExpression expression);
 
     boolean visitPatternValue(EJBQLExpression expression);
 

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLDbPath.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLDbPath.java?rev=609391&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLDbPath.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ejbql/parser/EJBQLDbPath.java
Sun Jan  6 12:06:25 2008
@@ -0,0 +1,32 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.ejbql.parser;
+
+import org.apache.cayenne.ejbql.EJBQLExpressionVisitor;
+
+public class EJBQLDbPath extends EJBQLPath {
+
+    public EJBQLDbPath(int id) {
+        super(id);
+    }
+
+    public void visit(EJBQLExpressionVisitor visitor) {
+        visitor.visitDbPath(this);
+    }
+}

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTDbPath.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTDbPath.java?rev=609391&r1=609390&r2=609391&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTDbPath.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTDbPath.java
Sun Jan  6 12:06:25 2008
@@ -100,8 +100,9 @@
     @Override
     public void encodeAsEJBQL(PrintWriter pw, String rootId) {
         // warning: non-standard EJBQL...
+        pw.print("db:");
         pw.print(rootId);
-        pw.print(".db:");
+        pw.print('.');
         pw.print(path);
     }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/jjtree/org/apache/cayenne/ejbql/EJBQLParser.jjt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/jjtree/org/apache/cayenne/ejbql/EJBQLParser.jjt?rev=609391&r1=609390&r2=609391&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/jjtree/org/apache/cayenne/ejbql/EJBQLParser.jjt
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/jjtree/org/apache/cayenne/ejbql/EJBQLParser.jjt
Sun Jan  6 12:06:25 2008
@@ -391,10 +391,23 @@
 }
 
 
-void path() #Path : { }
+void path() : { }
 {
 	// a path is any dot-separated path expression starting with a
 	// non-reserved word
+	
+	db_path() | object_path()
+}
+
+void db_path() #DbPath : { }
+{
+	// Cayenne extension: DBPath... there's no such thing in EJBQL 
+	
+	"db:" identification_variable() (<DOT> path_component())+
+}
+
+void object_path() #Path : { }
+{
 	identification_variable() (<DOT> path_component())+
 }
 
@@ -1060,7 +1073,7 @@
 
 void identification_variable() #Identifier :
 { Token t; }
-{
+{  
 	t = <IDENTIFIER> { jjtThis.setText (t.image); }
 }
 

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/ejbql/EJBQLExpressionTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/ejbql/EJBQLExpressionTest.java?rev=609391&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/ejbql/EJBQLExpressionTest.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/ejbql/EJBQLExpressionTest.java
Sun Jan  6 12:06:25 2008
@@ -0,0 +1,33 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.ejbql;
+
+import org.apache.cayenne.unit.CayenneCase;
+
+public class EJBQLExpressionTest extends CayenneCase {
+
+    public void testDbPath() {
+
+        EJBQLParser parser = EJBQLParserFactory.getParser();
+
+        EJBQLExpression select = parser
+                .parse("select p from Painting p WHERE db:p.toArtist.ARTIST_NAME = 'a'");
+        assertNotNull(select);
+    }
+}



Mime
View raw message