Section 22.214.171.124 of the JPA 2.1 specification (which gives the syntax for path expressions) explicitly allows nested "treat as" statements, yet they are not currently supported by Hibernate. The following test case throws a QuerySyntaxExpression:
The stacktrace of the thrown expression is:
My pull request for added support for nested "treat as" just after a "member of" construction, but it is currently the only place where nested treat as are supported. This new bug report is in order to support them everywhere where they should be allowed.