|
The SQL spec does not contain the wording "table specifications" so I can't tell you anything about that. In the section 7.5 4a) it is mentioned that the join condition may reference any columns from the participating table references or outer table references. I can tell that there are databases that require the table references to be ordered in a way that respects the dependencies. If an ON clause has a reference to a table reference, the table reference must come before the ON clause. You can imagine that like building an acyclic graph of table reference nodes. Each node is connected to other nodes that it's conditional clause depends on. Just traverse the "tree" and render table references but try to render all dependencies first. This will guarantee that table references are available for conditions. Since aliases in JPQL and HQL are only available after they are defined in the FROM clause wrt left to right reading, I would expect that the order in the rendered SQL is just preserved. I can't tell how often that is used in practice but I think it is legitimate to expect hibernate to allow this usage, especially since the fix would only involve NOT throwing an exception for that case. I don't see a reason for not allowing it, but please correct me if I don't see the apparent.
|