Is there any way to generate SQLite database model from Java code using JOOQ?
1 Answer
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/
2 Comments
Peter Penzov
Can you give some example what is SCHEMA? Are these Java classes similar to JPA Entities?
Lukas Eder
@PeterPenzov: It's a generated schema reference. But hey, perhaps I misunderstood your question. Would you mind being explicit about what you'd like to do?