Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Trying to use OPERATOR fails
Trying to use OPERATOR fails [message #868827] Wed, 02 May 2012 15:46 Go to next message
Thomas Mauch is currently offline Thomas MauchFriend
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)
Re: Trying to use OPERATOR fails [message #869524 is a reply to message #868827] Thu, 03 May 2012 14:34 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

This requires EclipseLink 2.4,

http://www.eclipse.org/eclipselink/downloads/milestones.php


James : Wiki : Book : Blog : Twitter
Re: Trying to use OPERATOR fails [message #869531 is a reply to message #869524] Thu, 03 May 2012 14:40 Go to previous messageGo to next message
Thomas Mauch is currently offline Thomas MauchFriend
Messages: 30
Registered: July 2009
Member
Do you have any idea when ElipseLink 2.4 should be released?
Re: Trying to use OPERATOR fails [message #869540 is a reply to message #869531] Thu, 03 May 2012 14:50 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

See, http://wiki.eclipse.org/EclipseLink/Development/2.4.0

James : Wiki : Book : Blog : Twitter
Previous Topic:Where Is The Documentation and Examples For Eclipselink Exceptions especially Persistence Exception
Next Topic:unexplained insert
Goto Forum:
  


Current Time: Thu Apr 25 09:46:35 GMT 2024

Powered by FUDForum. Page generated in 0.03364 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top