Yeah, heh, "the unique key" - but which one? A table can only have one
"primary key", thus the name "primary". But it can have any number of
"unique" keys, so it would be unwise to just pick any key at random.

You can, however, specify "override primary keys" or "synthetic primary
keys" in the absence of actual primary keys:

-
https://www.jooq.org/doc/latest/manual/code-generation/codegen-advanced/codegen-config-database/codegen-database-override-primary-keys/
-
https://www.jooq.org/doc/latest/manual/code-generation/codegen-advanced/codegen-config-database/codegen-database-synthetic-primary-keys/

I hope this helps,
Lukas

2018-05-09 21:40 GMT+02:00 <[email protected]>:

> I've a table that does not have a primary key but a composite key that is
> unique. In the absence of a primary key, the code in
> JavaGenerator.generateDao() is skipping DAO generation. Shouldn't it
> instead attempt to pick the unique key, if present, as shown below? Also, I
> recommend that a warn message be generated instead of an info message under
> such circumstances.
>
>         UniqueKeyDefinition key = table.getPrimaryKey();
>         if (key == null) {
>             if (table.getUniqueKeys().isEmpty()){
>                 Log.warn("Skipping DAO generation", out.file().getName());
>                 return;
>             } else {
>                 key = table.getUniqueKeys().get(0);
>             }
>         }
>
> --
> You received this message because you are subscribed to the Google Groups
> "jOOQ User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to