Affects Version/s: 5.1.4, 5.2.8
Fix Version/s: 5.2.9
Redundant left outer joins generated in SQL query when HQL query contains left join on some entity (not by primary key).
HQL: select c.inventoryNumber from Employee e left join Computer c on c.workplace = e.workplace
And if there is join by primary key: select c.inventoryNumber from Employee e left join Computer c on c.workplace*.id* = e.workplace*.id*
Then the generated SQL looks like:
No redundant joins here.
The problem is that such SQL significantly impacts performance when selecting from several large tables.
To reproduce you can run the following test and see the generated query in output: org.hibernate.bugs.QueryGenerationTestCase#testRedundantSqlJoins