From 14eeab2c00efc8df2ad15b35136e85c63852158c Mon Sep 17 00:00:00 2001 From: Catalina Wei Date: Sun, 4 May 2008 03:26:24 +0000 Subject: [PATCH] OPENJPA-573 JPQL: The combination LIKE ESCAPE does not accept parameters git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@653176 13f79535-47bb-0310-9956-ffa450edef68 --- .../jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt | 2 +- .../jpql/expressions/TestEJBQLCondExpression.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt b/openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt index 2e6d530ee..9a40e45fb 100644 --- a/openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt +++ b/openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt @@ -1250,7 +1250,7 @@ void positional_input_parameter() #POSITIONALINPUTPARAMETER : void pattern_value() #PATTERNVALUE : { } { - input_parameter() | string_literal() + (input_parameter() | string_literal()) [( escape_character() #ESCAPECHARACTER)] } diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/expressions/TestEJBQLCondExpression.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/expressions/TestEJBQLCondExpression.java index 9b1fa80d7..4e71644f4 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/expressions/TestEJBQLCondExpression.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/expressions/TestEJBQLCondExpression.java @@ -23,7 +23,6 @@ import javax.persistence.EntityManager; import org.apache.openjpa.persistence.common.apps.*; import org.apache.openjpa.persistence.common.utils.AbstractTestCase; -import org.apache.openjpa.persistence.InvalidStateException; public class TestEJBQLCondExpression extends AbstractTestCase { @@ -163,6 +162,13 @@ public class TestEJBQLCondExpression extends AbstractTestCase { assertNotNull(result); assertEquals(0, result.size()); + query = "SELECT o.name FROM CompUser o WHERE o.name LIKE ?1 ESCAPE '|'"; + + result = em.createQuery(query).setParameter(1, "%|_%").getResultList(); + + assertNotNull(result); + assertEquals(0, result.size()); + endEm(em); } @@ -268,7 +274,7 @@ public class TestEJBQLCondExpression extends AbstractTestCase { String query = "SELECT o.name FROM CompUser o WHERE o.address.zipcode = ANY (" + - " SELECT s FROM CompUser s WHERE s.address.country IS NOT NULL )"; + " SELECT s.computerName FROM CompUser s WHERE s.address.country IS NOT NULL )"; List result = em.createQuery(query).getResultList();