|
When I mentioned "cross join" in my original bug report, I meant the combination of the Student entity with the Question entity in a single "from" clause. In the official Hibernate documentation of that time, combining two entities in a single "from" clause was called "cross join": http://docs.jboss.org/hibernate/orm/4.3/manual/en-US/html_single/#queryhql-from . That's why I used that term.
Anyway, the problem is not the "cross join". The failure appears not only when you reference an entity that was "cross-joined", but also when you reference an entity that it's not the first one in the "from" clause. For example, one that you've referenced using a "join" or "inner join", be it explicit or implicit.
For example, let's suppose that we want to obtain a list of the students and also the tests, of their preferred subject, that they've made. Let's suppose that they may have not made any test of that subject, but that we still want the information about the student. We would write:
SELECT student, madeTest FROM Student student JOIN student.preferredSubject preferredSubject LEFT JOIN student.madeTests madeTest ON madeTest.subject.id = preferredSubject.id
This simple query will trigger the exception. The query can be simplified to use the "join" implicitly:
SELECT student, madeTests FROM Student student LEFT JOIN student.madeTests madeTests ON madeTests.subject.id = student.preferredSubject.id
This also triggers the exception. However, there isn't anything that it's illegal "per-se", Right? I mean, in all the database engines that I've used I've been able to reference another table in the "on" condition of a "left join" or "right join", as long as the table has been joined previously.
It's true that I don't know the impact of this issue in other user cases. It's complicated to tell because, in contrast to other issues, they can use pure SQL to avoid this one, without complaining. But I believe that this use of the "outer join" is very common. Indeed, referencing another table in an "outer join" clause is the "raison d'être" of this kind of join. Internally, it's what Hibernate does when you just write a "left join" without the "on" condition. So, Why not to allow the user be more explicit with that condition?
Thank you for your effort.
|