Generate SQLite database scheme from Java code

807 Views Asked by At

Is there any way to generate SQLite database model from Java code using JOOQ?

1

There are 1 best solutions below

2
On

You can generate DDL statements like CREATE TABLE .. or ALTER TABLE .. ADD CONSTRAINT .. using the DSLContext.ddl() API, for instance:

// SCHEMA is the generated schema that contains a reference to all generated tables
Queries ddl =
DSL.using(configuration)
   .ddl(SCHEMA);

for (Query query : ddl.queries()) {
    System.out.println(query);
}

This is documented here: https://www.jooq.org/doc/latest/manual/sql-building/ddl-statements/generating-ddl/