Is there a posibility to generate value-object wrappers for primary keys in JOOQ?

37 Views Asked by At

for example, there is a table:

table product (id UUID, name varchar)

Is it possible to generate for this table classes like code bellow?

class ProductIdentifier {
    UUID id;
}

class Product {
    ProductIdentifier id;
    String name;
}

I'm just asking. I didn't try

1

There are 1 best solutions below

0
Lukas Eder On

Yes, the feature is called "embedded keys", where the code generator automatically generates an embeddable type (single column or composite, it doesn't matter) for both:

  • Primary keys
  • All referencing foreign keys

Of course, you can also do this manually, yourself, by declaring embeddable types for each key.