In queries, we dereference implicit joins for primary keys where possible. The same can however be done for natural keys (mapped to the referencedColumnName of a JoinColumn) as well.
The following examples use the following domain:
For example, consider the following HQL queries:
Which could be derived from the SQL FROM clause, but actually joins BOOK to get the same column value.
Due to the implicit join in the on clause, this query currently fails with an exception. With the optimisation, this query would produce two SQL joins.
Without the optimisation, this query produces 5 joins. With the optimisation, this query produces 3 joins.