Trying to use OPERATOR fails [message #868827] |
Wed, 02 May 2012 15:46 |
Thomas Mauch Messages: 30 Registered: July 2009 |
Member |
|
|
I try to use the OPERATOR functionality as described in
http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying/Support_for_Native_Database_Functions#OPERATOR
So my query looks like this:
return em.createQuery(
"SELECT e from JpaEntity e WHERE operator('DatePart', e.dateTime, 'year') = ?1")
.setParameter(1, year).getResultList();
However, I always receive the following syntax error.
Obviously, the error is not in how the arguments are passed (which I am not sure whether this is correct like this), but the keyword OPERATOR is not recognized.
FUNC on the other hand works fine. I also tried to look at the parser but did not find any notion of OPERATOR, but only FuncNode.java.
What am I missing?
Thanks,
Thomas
Exception in thread "main" java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
Exception Description: Syntax error parsing the query [SELECT e from JpaEntity e WHERE operator('DatePart', e.dateTime, 'year') = ?1], line 1, column 40: unexpected token [(].
Internal Exception: NoViableAltException(83@[()* loopback of 383:9: (d= DOT right= attribute )*])
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1477)
at eval.jpa.EvalJpa.readYear2(EvalJpa.java:99)
at eval.jpa.EvalJpa.test(EvalJpa.java:49)
at eval.jpa.EvalJpa.main(EvalJpa.java:13)
Caused by: Exception [EclipseLink-8025] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Syntax error parsing the query [SELECT e from JpaEntity e WHERE operator('DatePart', e.dateTime, 'year') = ?1], line 1, column 40: unexpected token [(].
Internal Exception: NoViableAltException(83@[()* loopback of 383:9: (d= DOT right= attribute )*])
at org.eclipse.persistence.exceptions.JPQLException.unexpectedToken(JPQLException.java:372)
at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.handleRecognitionException(JPQLParser.java:320)
at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.addError(JPQLParser.java:246)
at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.reportError(JPQLParser.java:363)
at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.pathExprOrVariableAccess(JPQLParser.java:1436)
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03971 seconds