Working with embedded keys
As part of the embeddable types introduced in Chapter 7, Types, Converters, and Bindings, we have jOOQ-embedded keys. An embedded key is materialized by the jOOQ Code Generator into the implementation of the jOOQ org.jooq.EmbeddableRecord
interface and a handy POJO class. An embedded key extends the default implementation of the org.jooq.EmbeddableRecord
interface, which is org.jooq.impl.EmbeddableRecordImpl
.
We can define embedded keys for primary and unique keys. Practically, we indicate to jOOQ the primary/unique keys that should become embedded keys, and jOOQ will generate the corresponding artifacts for each primary/unique key, as well as for each foreign key referencing these primary/unique keys. Roughly, embedded keys mirror the primary/unique keys and the corresponding foreign keys in Java classes.
However, in order to employ embedded keys, we need the following configuration:
// Maven and standalone <database> ... ...