We're updating the issue view to help you get more done. 

Misleading replacement of commas with cross joins

Description

There was a new feature implemented in 3.5.0-Beta-2: HHH-1480, as a result, for many dialects, the comma operator "," was replaced with "cross join". As it's already obvious from the feature's description, this changes join precedence. If the query contains outer joins (left or right) this replacement changes the results (because outer join precedence is important).
This might not be interpreted as a bug if you know what SQL operator will be generated when you place a comma in HQL, but it's misleading if you don't. A HQL query like:

1 select a from A a, B left join B.c c

is not equivalent with the SQL query:

1 select a.* from A.a, B b left join C c on b.cid = c.id

because the actual SQL query is:

1 select a.* from A.a cross join B b left join C c on b.cid = c.id

The first SQL query would make a left join on B and C and then a cross join with the result and A (and this is what we should expect). The second SQL query makes a cross join on A and B and then a left join with the result and C (this is not expected since we had a comma in HQL).

I understand the issues presented in HHH-1480, but they should be expected, i.e. a developer SHOULD expect a faliure from a query like

1 select a from A a, B b join a.c C

because "a" is not visible in the join. Hibernate should not use a cross join behind the scenes to allow such a query at the expense of providing misleading results for others.

Maybe turn this into a feature/improvement or add another to allow explicit comma or croos join in HQL, or support parenthesis in HQL.

The only workaround I can see for now is to re-order the query like this:

1 select a from B left join B.c c, A a

Environment

Hibernate 3.5.3
Ms SQL Server 2005

Status

Assignee

Unassigned

Reporter

Vlad Patras

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

3.6.0
3.5.2
3.5.3
3.5.1
3.5.0-Beta-4
3.5.0-CR-2
3.5.0-Final
3.5.0-Beta-3
3.5.0-CR-1
3.5.0-Beta-2

Priority

Major