geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From CG <learn....@gmail.com>
Subject JPQL named parameter does not work
Date Tue, 15 Apr 2008 00:31:54 GMT
Hi all ,
  I have experienced this , where the createQuery function using named
parameter cause parsing problem
<code>
		System.out.println("List some materials");
		List<Material> someMaterials =
(List<Material>)em.createQuery("SELECT m FROM Material m WHERE
m.mat_Description=:desc").setParameter("desc", "Raw
Material").getResultList();
</code>
I have tried with positional parameter, replacing :desc with ?1  and
it works , so I wonder is the openjpa version built-in in geronimo 2.1
does not support named parameter ?
Has anybody manage to get named parameter works ? I do not try the
NameQuery() method yet , if someone has tried maybe can share with us
whether it works or not.

Thanks.
CG

Error message detail
=================================
		
Exception in thread "main" javax.ejb.EJBException: The bean
encountered a non-application exception.; nested exception is:
	<openjpa-1.0.1-r420667:592145 nonfatal user error>
org.apache.openjpa.persistence.ArgumentException: An error occurred
while parsing the query filter 'SELECT m FROM Material m WHERE
m.mat_Description=:desc'. Error message: <openjpa-1.0.1-r420667:592145
nonfatal user error> org.apache.openjpa.kernel.jpql.ParseException:
Encountered "m . mat_Description = : desc" at character 32, but
expected: ["(", "*", "+", "-", ".", "/", ":", "<", "<=", "<>", "=",
">", ">=", "?", "ABS", "ALL", "AND", "ANY", "AS", "ASC", "AVG",
"BETWEEN", "BOTH", "BY", "CONCAT", "COUNT", "CURRENT_DATE",
"CURRENT_TIME", "CURRENT_TIMESTAMP", "DELETE", "DESC", "DISTINCT",
"EMPTY", "ESCAPE", "EXISTS", "FETCH", "FROM", "GROUP", "HAVING", "IN",
"INNER", "IS", "JOIN", "LEADING", "LEFT", "LENGTH", "LIKE", "LOCATE",
"LOWER", "MAX", "MEMBER", "MIN", "MOD", "NEW", "NOT", "NULL",
"OBJECT", "OF", "OR", "ORDER", "OUTER", "SELECT", "SET", "SIZE",
"SOME", "SQRT", "SUBSTRING", "SUM", "TRAILING", "TRIM", "UPDATE",
"UPPER", "WHERE", <BOOLEAN_LITERAL>, <DECIMAL_LITERAL>, <IDENTIFIER>,
<INTEGER_LITERAL>, <STRING_LITERAL>].
	at org.apache.openejb.client.EJBInvocationHandler.convertException(EJBInvocationHandler.java:210)
	at org.apache.openejb.client.EJBObjectHandler._invoke(EJBObjectHandler.java:157)
	at org.apache.openejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:116)
	at org.apache.openejb.client.proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:52)
	at $Proxy0.testMaterial(Unknown Source)
	at test.com.quesofttech.FirstEJB3TutorialClient.main(FirstEJB3TutorialClient.java:51)
Caused by: <openjpa-1.0.1-r420667:592145 nonfatal user error>
org.apache.openjpa.persistence.ArgumentException: An error occurred
while parsing the query filter 'SELECT m FROM Material m WHERE
m.mat_Description=:desc'. Error message: <openjpa-1.0.1-r420667:592145
nonfatal user error> org.apache.openjpa.kernel.jpql.ParseException:
Encountered "m . mat_Description = : desc" at character 32, but
expected: ["(", "*", "+", "-", ".", "/", ":", "<", "<=", "<>", "=",
">", ">=", "?", "ABS", "ALL", "AND", "ANY", "AS", "ASC", "AVG",
"BETWEEN", "BOTH", "BY", "CONCAT", "COUNT", "CURRENT_DATE",
"CURRENT_TIME", "CURRENT_TIMESTAMP", "DELETE", "DESC", "DISTINCT",
"EMPTY", "ESCAPE", "EXISTS", "FETCH", "FROM", "GROUP", "HAVING", "IN",
"INNER", "IS", "JOIN", "LEADING", "LEFT", "LENGTH", "LIKE", "LOCATE",
"LOWER", "MAX", "MEMBER", "MIN", "MOD", "NEW", "NOT", "NULL",
"OBJECT", "OF", "OR", "ORDER", "OUTER", "SELECT", "SET", "SIZE",
"SOME", "SQRT", "SUBSTRING", "SUM", "TRAILING", "TRIM", "UPDATE",
"UPPER", "WHERE", <BOOLEAN_LITERAL>, <DECIMAL_LITERAL>, <IDENTIFIER>,
<INTEGER_LITERAL>, <STRING_LITERAL>].
	at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.parse(JPQLExpressionBuilder.java:1666)
	at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.<init>(JPQLExpressionBuilder.java:1646)
	at org.apache.openjpa.kernel.jpql.JPQLParser.parse(JPQLParser.java:47)
	at org.apache.openjpa.kernel.ExpressionStoreQuery.newCompilation(ExpressionStoreQuery.java:144)
	at org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:651)
	at org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:633)
	at org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:599)
	at org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:661)
	at org.apache.openjpa.kernel.QueryImpl.getOperation(QueryImpl.java:1487)
	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 com.quesofttech.session.MaterialTestBean.testMaterial(MaterialTestBean.java:30)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:146)
	at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:129)
	at org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:67)
	at org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:210)
	at org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:188)
	at org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:165)
	at org.apache.openejb.server.ejbd.EjbRequestHandler.doEjbObject_BUSINESS_METHOD(EjbRequestHandler.java:214)
	at org.apache.openejb.server.ejbd.EjbRequestHandler.processRequest(EjbRequestHandler.java:121)
	at org.apache.openejb.server.ejbd.EjbDaemon.processEjbRequest(EjbDaemon.java:164)
	at org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:122)
	at org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:84)
	at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:60)
	at org.apache.openejb.server.ServiceLogger.service(ServiceLogger.java:76)
	at org.apache.openejb.server.ServiceAccessController.service(ServiceAccessController.java:55)
	at org.apache.openejb.server.ServiceDaemon$1.run(ServiceDaemon.java:118)
	at java.lang.Thread.run(Thread.java:619)

Mime
View raw message