
jOOQ Masterclass
By :

Embeddable types represent a powerful feature introduced in jOOQ 3.14. Roughly, this feature gets materialized in synthetic UDTs that can be used with all databases supported by jOOQ. While PostgreSQL and Oracle support UDTs (we can use UDTs directly in Data Definition Language (DDL)), other databases including MySQL and SQL Server don't support UDTs. But via jOOQ embeddable types, we can work at the application level with synthetic UDTs for any database, and jOOQ will take care of the underlying aspects of mapping these types to the database.
An embeddable type mimics a UDT by synthetically wrapping one (usually more) database column in a generated org.jooq.EmbeddableRecord
. For instance, we can wrap OFFICE.CITY
, OFFICE.STATE
, OFFICE.COUNTRY
, OFFICE.TERRITORY
, and OFFICE.ADDRESS_LINE_FIRST
under an embeddable type named OFFICE_FULL_ADDRESS
via the following configuration in the jOOQ Code Generator (here, for MySQL):
<embeddable> <!-...