Collection member declaration not handling optional AS in HQL.

Description

HQL:

SELECT o FROM EntityBean AS o, IN (o.items) AS l WHERE l.itemValue = '1'

The log output gives the following:

2010-11-10 16:03:53,286 DEBUG [org.hibernate.hql.ast.QueryTranslatorImpl] (WorkerThread#0[127.0.0.1:60518]) parse() - HQL: SELECT o FROM EntityBean AS o, IN (o.items) AS l WHERE l.itemValue = '1'

2010-11-10 16:03:53,290 DEBUG [org.hibernate.hql.PARSER] (WorkerThread#0[127.0.0.1:60518]) Keyword 'AS' is being interpreted as an identifier due to: expecting IDENT, found 'AS'

2010-11-10 16:03:53,403 ERROR [org.hibernate.hql.PARSER] (WorkerThread#0[127.0.0.1:60518]) line 1:48: unexpected token: l

According to the jpa persistence spec the AS keyword is optional for collection declarations:

collection_member_declaration ::=
IN (collection_valued_path_expression) [AS] identification_variable

In hql.g we have:

inCollectionDeclaration!
: IN! OPEN! path CLOSE! a:alias
{ #inCollectionDeclaration = #([JOIN, "join"], [INNER, "inner"], #p, #a); }
;

Should this be a:asAlias rather than a:alias?

Workaround: Do not use option AS, only identifier in the HQL for collection.

Environment

None

Activity

Show:
Dave Stephan
November 11, 2010, 1:44 AM
Strong Liu
December 13, 2010, 12:00 PM

NOTE: currently, only fixed in org.hibernate.hql.ast.ASTQueryTranslatorFactory, but org.hibernate.hql.classic.ClassicQueryTranslatorFactory

Strong Liu
December 13, 2010, 8:39 PM

reopen to add org.hibernate.hql.classic.ClassicQueryTranslatorFactory support, meanwhile, this can be workaround by something like "from Order o, i in elements(o.items)"

Steve Ebersole
March 21, 2011, 7:07 PM

Bulk closing stale resolved issues

Assignee

Strong Liu

Reporter

Dave Stephan

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

Affirmative

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure