I am using JOOQ(newbie in JOOQ) to create the database at runtime using Rest API in my spring boot project. In one of the case I need to create a table with a composite primary key which can be combination of multiple columns. I am using the below piece of code to create constraint -
ArrayList<Constraint> constraints = new ArrayList<>();
constraints.add(constraint(name("pk_" + tableName))
.primaryKey(field("column1"), field("column2")));
I already have List<Field<?>>
which will be working as the composite primary key.
How can I make this dynamic as the primary key constraint can support n number of columns?
Is there any way I can directly provide the field list in the .primarykey()
API?