Available in versions: Dev (3.20) | Latest (3.19) | 3.18 | 3.17

Tables as SelectField

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

An org.jooq.Table expression extends the org.jooq.SelectField type, and as such, can be used in the SELECT clause directly, as well as everywhere else a SelectField is accepted, e.g. in nested records. This is specifically useful for (generated) table references. The following shows how to project a nested org.jooq.TableRecord:

Result<Record2<AuthorRecord, BookRecord>> result =
create.select(AUTHOR, BOOK)

This plays very well together with implicit joins:

Result<Record2<AuthorRecord, BookRecord>> result =
create.select(BOOK.author(), BOOK)

Behind the scenes, the implementation may either be native in dialects that support this kind of projection (e.g. PostgreSQL), or emulated using the usual nested records emulations.

References to this page


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

The jOOQ Logo