Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » JPQL subquery error(JPQL subquery error)
JPQL subquery error [message #630543] Mon, 04 October 2010 00:23 Go to next message
Kiran  is currently offline Kiran Friend
Messages: 8
Registered: October 2010
Junior Member
A simple subquery in a namedQuery is failing. Please let me know what might be causing this error. Thanks for your help.

I am getting an error in the following NamedQuery

@NamedQuery(name = "OaaFlexrolesUnitT.findFlexRolesAvailableUsers",
query = "select c.netId,a.emplname from IsiEdbBasT a,NyuEdbEmpT b,OaaUserRolesT c where a.emplid=b.emplid and a.emplstat <> 'X' and a.orgid = ' ' and a.qtrno = 0 and a.orgid = b.orgid and a.qtrno = b.qtrno and b.netid = c.netId and c.roleId = :role1 and c.netId not in (select netid from OaaFlexrolesUnitT where unit = :unit and division = :division and roleId = :role2)")

Exception is
Exception [EclipseLink-8025] (Eclipse Persistence Services - 1.0.2 (Build 20081024)): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Syntax error parsing the query [OaaFlexrolesUnitT.findFlexRolesAvailableUsers:
line 1, column 279: unexpected token [OaaFlexrolesUnitT].
Internal Exception: NoViableAltException(66!=[1108:1: subselectIdentificationVariableDeclaration[List varDecls] : ( identificationVariableDeclaration[varDecls] | n= associationPathExpression ( AS )? i= IDENT | n= collectionMemberDeclaration );])
at org.eclipse.persistence.exceptions.JPQLException.unexpectedT oken(JPQLException.java:365)
at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser .handleRecognitionException(JPQLParser.java:319)
at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser .addError(JPQLParser.java:245)
at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser .reportError(JPQLParser.java:362)
at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQL Parser.subselectIdentificationVariableDeclaration(JPQLParser .java:11272)
at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQL Parser.subqueryFromClause(JPQLParser.java:11002)
at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQL Parser.subquery(JPQLParser.java:10719)
at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQL Parser.inExpression(JPQLParser.java:7536)
at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQL Parser.conditionWithNotExpression(JPQLParser.java:7278)
at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQL Parser.simpleConditionalExpressionRemainder(JPQLParser.java: 7149)
at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQL Parser.simpleConditionalExpression(JPQLParser.java:7043)
at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQL Parser.conditionalPrimary(JPQLParser.java:6997)
at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQL Parser.conditionalFactor(JPQLParser.java:2989)
at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQL Parser.conditionalTerm(JPQLParser.java:2903)
at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQL Parser.conditionalExpression(JPQLParser.java:2805)
at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQL Parser.whereClause(JPQLParser.java:2762)
at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQL Parser.selectStatement(JPQLParser.java:356)
at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQL Parser.document(JPQLParser.java:261)
at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser .parse(JPQLParser.java:133)
Re: JPQL subquery error [message #630625 is a reply to message #630543] Mon, 04 October 2010 12:34 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1039
Registered: July 2009
Senior Member
Hello,

The subquery is invalid. Try something like:
"select oaa.netid from OaaFlexrolesUnitT a where oaa.unit = :unit and oaa.division = :division and oaa.roleId = :role2"

Best Regards,
Chris
Re: JPQL subquery error [message #630725 is a reply to message #630625] Mon, 04 October 2010 17:22 Go to previous message
Kiran  is currently offline Kiran Friend
Messages: 8
Registered: October 2010
Junior Member
That worked and saved me a lot of time. It was a silly oversight on my part not to have included the object alias in the subquery. Thanks a lot for pointing it out.

Regards
Kiran
Previous Topic:Compatibility of TABLE_PER_CLASS inheritance strategy with composite keys
Next Topic:Problem with bidirectional OneToMany relationship
Goto Forum:
  


Current Time: Sun Dec 21 20:13:18 GMT 2014

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

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