Avoid join on property access mapped by natural id

Description

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:

1.

Which could be derived from the SQL FROM clause, but actually joins BOOK to get the same column value.

2.

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.

3.

Without the optimisation, this query produces 5 joins. With the optimisation, this query produces 3 joins.

Environment

None

Assignee

Jan-Willem Gmelig Meyling

Reporter

Jan-Willem Gmelig Meyling

Fix versions

Labels

None

backPortable

Backport?

Suitable for new contributors

None

Requires Release Note

None

backportDecision

None

Priority

Minor
Configure