You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Georgi Naplatanov (JIRA)" <ji...@apache.org> on 2008/04/17 01:03:22 UTC
[jira] Updated: (OPENJPA-573) JPQL: The combination LIKE ESCAPE
does not accept parameters
[ https://issues.apache.org/jira/browse/OPENJPA-573?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Georgi Naplatanov updated OPENJPA-573:
--------------------------------------
Fix Version/s: (was: 1.1.0)
Affects Version/s: 1.1.0
> JPQL: The combination LIKE ESCAPE does not accept parameters
> ------------------------------------------------------------
>
> Key: OPENJPA-573
> URL: https://issues.apache.org/jira/browse/OPENJPA-573
> Project: OpenJPA
> Issue Type: Bug
> Affects Versions: 1.0.2, 1.1.0
> Environment: SUN JDK 1.6.0.6 (AMD64) for Linux
> Reporter: Georgi Naplatanov
>
> If i use constants like this :
> SELECT object FROM MyObject object WHERE object.path LIKE '%|_%' ESCAPE '|'
> all is ok, but if I want to use parameters - exception is thrown.
> Example:
> @Entity
> @Table(name="simple_object")
> public class MySimpleObject {
> @Id
> String Id ;
>
> @Basic
> @Column(name="value", nullable=false, length=36)
> String value ;
> .....................
> .......................
> EntityManager em = emf.createEntityManager() ;
> Query q = em.createQuery("SELECT x FROM MySimpleObject x WHERE x.value LIKE ?1 ESCAPE '|'") ;
> q.setParameter(1, "%|_%") ;
> List<MySimpleObject> res = q.getResultList() ;
> Exception in thread "main" <openjpa-1.1.0-SNAPSHOT-r422266:648359 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: Encountered "ESCAPE" at character 54, but expected: ["AND", "GROUP", "HAVING", "OR", "ORDER", <EOF>].
> at org.apache.openjpa.kernel.jpql.JPQL.generateParseException(JPQL.java:9499)
> at org.apache.openjpa.kernel.jpql.JPQL.jj_consume_token(JPQL.java:9376)
> at org.apache.openjpa.kernel.jpql.JPQL.parseQuery(JPQL.java:75)
> at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.parse(JPQLExpressionBuilder.java:1733)
> at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.<init>(JPQLExpressionBuilder.java:1720)
> at org.apache.openjpa.kernel.jpql.JPQLParser.parse(JPQLParser.java:48)
> at org.apache.openjpa.kernel.ExpressionStoreQuery.newCompilation(ExpressionStoreQuery.java:149)
> at org.apache.openjpa.datacache.QueryCacheStoreQuery.newCompilation(QueryCacheStoreQuery.java:239)
> at org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:656)
> at org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:638)
> at org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:604)
> at org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:666)
> at org.apache.openjpa.kernel.QueryImpl.getOperation(QueryImpl.java:1486)
> at org.apache.openjpa.kernel.DelegatingQuery.getOperation(DelegatingQuery.java:123)
> at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:227)
> at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:277)
> at Tester.testEscape(Tester.java:75)
> at Tester.main(Tester.java:93)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
Re: [jira] Updated: (OPENJPA-573) JPQL: The combination LIKE ESCAPE does not accept parameters
Posted by catalina wei <ca...@gmail.com>.
Hi Georgi,
This is a problem in
openjpa-kernel/src/main/java/org/apache/openjpa/kernel/JPQL.jjt
An easy fix is on this line:
input_parameter() | string_literal()
changed the above line to add parenthesis around it as the following, it
will get pass parser error.
(input_parameter() | string_literal())
void pattern_value() #PATTERNVALUE : { }
{
// originally was: input_parameter() | string_literal(), and changed to
the following:
(input_parameter() | string_literal())
[(<ESCAPE> escape_character() #ESCAPECHARACTER)]
}
Could you give it a try ?
You will need to run "mvn clean install" or "mvn compile" to regenerate the
parser.
I tried this fix, and for JPQL query: select c from Customer c where
c.nameLIKE ?1 ESCAPE '|'] with parameters: {1=%|_%}
I get this SQL
SELECT ... FROM TCUSTOMER t0 WHERE (t0.name LIKE ? ESCAPE '|')
[params=(String) %|_%]
Catalina
On Wed, Apr 16, 2008 at 4:03 PM, Georgi Naplatanov (JIRA) <ji...@apache.org>
wrote:
>
> [
> https://issues.apache.org/jira/browse/OPENJPA-573?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel]
>
> Georgi Naplatanov updated OPENJPA-573:
> --------------------------------------
>
> Fix Version/s: (was: 1.1.0)
> Affects Version/s: 1.1.0
>
> > JPQL: The combination LIKE ESCAPE does not accept parameters
> > ------------------------------------------------------------
> >
> > Key: OPENJPA-573
> > URL: https://issues.apache.org/jira/browse/OPENJPA-573
> > Project: OpenJPA
> > Issue Type: Bug
> > Affects Versions: 1.0.2, 1.1.0
> > Environment: SUN JDK 1.6.0.6 (AMD64) for Linux
> > Reporter: Georgi Naplatanov
> >
> > If i use constants like this :
> > SELECT object FROM MyObject object WHERE object.path LIKE '%|_%' ESCAPE
> '|'
> > all is ok, but if I want to use parameters - exception is thrown.
> > Example:
> > @Entity
> > @Table(name="simple_object")
> > public class MySimpleObject {
> > @Id
> > String Id ;
> >
> > @Basic
> > @Column(name="value", nullable=false, length=36)
> > String value ;
> > .....................
> > .......................
> > EntityManager em = emf.createEntityManager() ;
> > Query q = em.createQuery("SELECT x FROM MySimpleObject x WHERE x.value
> LIKE ?1 ESCAPE '|'") ;
> > q.setParameter(1, "%|_%") ;
> > List<MySimpleObject> res = q.getResultList() ;
> > Exception in thread "main" <openjpa-1.1.0-SNAPSHOT-r422266:648359
> nonfatal user error> org.apache.openjpa.persistence.ArgumentException:
> Encountered "ESCAPE" at character 54, but expected: ["AND", "GROUP",
> "HAVING", "OR", "ORDER", <EOF>].
> > at
> org.apache.openjpa.kernel.jpql.JPQL.generateParseException(JPQL.java:9499)
> > at
> org.apache.openjpa.kernel.jpql.JPQL.jj_consume_token(JPQL.java:9376)
> > at org.apache.openjpa.kernel.jpql.JPQL.parseQuery(JPQL.java:75)
> > at
> org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.parse(JPQLExpressionBuilder.java:1733)
> > at
> org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.<init>(JPQLExpressionBuilder.java:1720)
> > at
> org.apache.openjpa.kernel.jpql.JPQLParser.parse(JPQLParser.java:48)
> > at
> org.apache.openjpa.kernel.ExpressionStoreQuery.newCompilation(ExpressionStoreQuery.java:149)
> > at
> org.apache.openjpa.datacache.QueryCacheStoreQuery.newCompilation(QueryCacheStoreQuery.java:239)
> > at
> org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:656)
> > at
> org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:638)
> > at
> org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:604)
> > at
> org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:666)
> > at
> org.apache.openjpa.kernel.QueryImpl.getOperation(QueryImpl.java:1486)
> > at
> org.apache.openjpa.kernel.DelegatingQuery.getOperation(DelegatingQuery.java:123)
> > at
> org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:227)
> > at
> org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:277)
> > at Tester.testEscape(Tester.java:75)
> > at Tester.main(Tester.java:93)
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>