Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Parsing error in JPQL query
Parsing error in JPQL query [message #630847] Tue, 05 October 2010 09:56 Go to next message
Kiran  is currently offline Kiran Friend
Messages: 8
Registered: October 2010
Junior Member
I have the following NamedQuery

OaaFlexrolesUnitT.findByRole: select distinct a.unit,b.unitName,a.division,b.divName,c.name,a.netid,a.empl name from OaaFlexrolesUnitT a, DeptDivUnitRepNyuT b, OaaRolesT c where a.unit = TRIM(BOTH FROM b.unitNo) and a.division = TRIM(BOTH FROM b.divNo) and a.roleId = c.roleId and a.roleId = :roleId order by to_number(a.unit),to_number(a.division)

This query is giving me the following exception

javax.ejb.EJBException: EJB Exception: : Local Exception Stack:
Exception [EclipseLink-8023] (Eclipse Persistence Services - 1.0.2 (Build 20081024)): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Syntax error parsing the query [OaaFlexrolesUnitT.findByRole: select distinct a.unit,b.unitName,a.division,b.divName,c.name,a.netid,a.empl name from OaaFlexrolesUnitT a, DeptDivUnitRepNyuT b, OaaRolesT c where a.unit = TRIM(BOTH FROM b.unitNo) and a.division = TRIM(BOTH FROM b.divNo) and a.roleId = c.roleId and a.roleId = :roleId order by to_number(a.unit),to_number(a.division)].
Internal Exception: org.eclipse.persistence.internal.libraries.antlr.runtime.Ear lyExitException

What might be causing the error. Is to_number not allowed in JPQL? Is there any equivalent or should I use native query?

Regards
Kiran
Re: Parsing error in JPQL query [message #632405 is a reply to message #630847] Tue, 12 October 2010 19:23 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

You should get a better exception, so please log the issue if you are using the latest release. to_number is not valid JPQL, use the FUNC keyword or a native SQL query.


James : Wiki : Book : Blog : Twitter
Previous Topic:Is it possible to use to_number function in JPQL
Next Topic:Strange behavior in loading entities
Goto Forum:
  


Current Time: Sun Nov 23 12:38:55 GMT 2014

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

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