JPA join with treat causes QuerySyntaxException: Invalid path

Description

Accessing property of associated subclass causes an error.
Testcase included. Bug does not occur in 5.1.0 and 5.2.0 versions.
5.1.0 ok
5.1.1 fail
5.2.0 ok
5.2.1 fail
5.2.2 fail

org.hibernate.hql.internal.ast.QuerySyntaxException: Invalid path: 'generatedAlias2.name' [select generatedAlias0 from org.hibernate.bugs.entity.Allocation as generatedAlias0 inner join generatedAlias0.resource as generatedAlias1 where generatedAlias2.name=aram0]
at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:74)
at org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:91)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:268)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:190)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:142)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:115)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:152)
at org.hibernate.internal.AbstractSharedSessionContract.getQueryPlan(AbstractSharedSessionContract.java:526)
at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:628)

Environment

None

Status

Assignee

Andrea Boriero

Reporter

Tony Cramer

Fix versions

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Critical
Configure