cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r546625 - 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/DataContextEJBQLQueryTest.java
Date Tue, 12 Jun 2007 20:33:46 GMT
Author: aadamchik
Date: Tue Jun 12 13:33:45 2007
New Revision: 546625

URL: http://svn.apache.org/viewvc?view=rev&rev=546625
Log:
CAY-803: EJBQL Parameters support
(named parameters)

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/DataContextEJBQLQueryTest.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=546625&r1=546624&r2=546625
==============================================================================
--- 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
Tue Jun 12 13:33:45 2007
@@ -81,6 +81,12 @@
 
         return true;
     }
+    
+    public boolean visitNamedInputParameter(EJBQLExpression expression) {
+        String parameter = context.bindNamedParameter(expression.getText());
+        context.append('$').append(parameter);
+        return true;
+    }
 
     public boolean visitNot(EJBQLExpression expression) {
         context.append(" NOT");
@@ -195,18 +201,6 @@
         }
     }
 
-    public boolean visitStringLiteral(EJBQLExpression expression) {
-        if (expression.getText() == null) {
-            context.append("null");
-        }
-        else {
-            // note that String Literal text is already wrapped in single quotes, with
-            // quotes that are part of the string escaped.
-            context.append(expression.getText()).append(" 'VARCHAR'");
-        }
-        return true;
-    }
-
     public boolean visitIntegerLiteral(EJBQLExpression expression) {
         if (expression.getText() == null) {
             context.append("null");
@@ -256,6 +250,18 @@
 
         String parameter = context.bindPositionalParameter(expression.getPosition());
         context.append('$').append(parameter);
+        return true;
+    }
+
+    public boolean visitStringLiteral(EJBQLExpression expression) {
+        if (expression.getText() == null) {
+            context.append("null");
+        }
+        else {
+            // note that String Literal text is already wrapped in single quotes, with
+            // quotes that are part of the string escaped.
+            context.append(expression.getText()).append(" 'VARCHAR'");
+        }
         return true;
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLQueryTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLQueryTest.java?view=diff&rev=546625&r1=546624&r2=546625
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLQueryTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLQueryTest.java
Tue Jun 12 13:33:45 2007
@@ -191,4 +191,15 @@
         List ps = createDataContext().performQuery(query);
         assertEquals(2, ps.size());
     }
+    
+    public void testSelectFromWhereDecimalNumberNamed() throws Exception {
+        createTestData("prepare");
+
+        String ejbql = "select P from Painting P WHERE p.estimatedPrice <= :param";
+        EJBQLQuery query = new EJBQLQuery(ejbql);
+        query.setParameter("param", new BigDecimal(5000.00));
+
+        List ps = createDataContext().performQuery(query);
+        assertEquals(2, ps.size());
+    }
 }



Mime
View raw message