For hql queries containig both explicit join with unrelated entity in from clause and implicit join with related entity (via path expression e1.e2.field) in select clause invalid SQL is generated.
simple test is here: https://github.com/stasal/hibernate-tests and in attached documents
HQL: select a.c.d, b.e from A a left join B b on b.z = a.z
From-clause for generated SQL will look something like following:
In SQL-99 comma has lesser precedence then join, that is why database tries to execute left join at first (for A and B) but the left side of join is just C entity (not (A, C) or (A cross join C)) that is why such SQL is not executed (RDBMS couldn't find the join column in C entity because it is in A entity which is not yet participating in From - it should be joined after "left join" operation).
To genereate correct SQL we need to substitute comma ", " with "cross join". In other words - use org.hibernate.dialect.Dialect#getCrossJoinSeparator method while generating SQL. But now there is a hardcoded ", " in method org.hibernate.hql.internal.ast.SqlGenerator#nestedFromFragment
Oracle Database 12c
Applied PR upstream.
Reopening to add 5.1.4 as a fix version.
Note 1: this was added in 4.2.16.
To genereate correct SQL we need to substitute comma ", " with "cross join". In other words - use org.hibernate.dialect.Dialect#getCrossJoinSeparator method while generating SQL.
Note 2: some dialects return just a comma (", ") from their getCrossJoinSeparator() implementations. E.g. DB2Dialect, TimesTenDialect. This is not a problem for me (I'm not using any of them), but this probably means this regression is still present on certain platforms.