New versions: Dev (3.15) | Latest (3.14)

Implicit join type

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

jOOQ's very useful implicit JOIN feature can be used to use a path notation to join tables on their actual, or synthetic foreign keys. For example:

// Get all books, their authors, and their respective language
create.select(
          BOOK.author().FIRST_NAME,
          BOOK.author().LAST_NAME,
          BOOK.TITLE,
          BOOK.language().CD.as("language"))
      .from(BOOK)
      .fetch();

By default, this produces:

  • An INNER JOIN if all columns of the foreign key are NOT NULL
  • A LEFT JOIN if the foreign key is nullable / optional

This behaviour means that implicit joins do not filter results when placed in clauses that are not meant to filter, such as the SELECT clause or the ORDER BY clause.

Users may prefer to enforce a different behaviour, including:

  • Always produce a LEFT JOIN, e.g. because this was the behaviour before jOOQ 3.14
  • Always produce an INNER JOIN, e.g. because they're migrating off Hibernate / JPA, and depend on Hibernate's implicit joins producing inner joins

This change of behaviour can be achieved with the following setting:

Example configuration

Settings settings = new Settings()
    .withRenderImplicitJoinType(RenderImplicitJoinType.INNER_JOIN);

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo