]
Gail Badner updated HHH-5352:
-----------------------------
Fix Version/s: (was: 4.0.0.Alpha1)
4.0.0.Alpha3
Misleading replacement of commas with cross joins
-------------------------------------------------
Key: HHH-5352
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5352
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.5.0-Beta-2, 3.5.0-Beta-3, 3.5.0-Beta-4, 3.5.0-CR-1, 3.5.0-CR-2,
3.5.0-Final, 3.5.1, 3.5.2, 3.5.3, 3.6.0
Environment: Hibernate 3.5.3
Ms SQL Server 2005
Reporter: Patras Vlad
Fix For: 3.6.next, 4.0.0.Alpha3
Attachments: commaAgainstCrossJoin.patch
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:
{noformat}select a from A a, B left join B.c c{noformat}
is not equivalent with the SQL query:
{noformat}select a.* from A.a, B b left join C c on b.cid = c.id{noformat}
because the actual SQL query is:
{noformat}select a.* from A.a cross join B b left join C c on b.cid = c.id{noformat}
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
{noformat}select a from A a, B b join a.c C{noformat}
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:
{noformat}select a from B left join B.c c, A a{noformat}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: