0

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

Peter Penzov
  • 1,126
  • 134
  • 430
  • 808

1 Answers1

1

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/

Lukas Eder
  • 211,314
  • 129
  • 689
  • 1,509
  • Can you give some example what is SCHEMA? Are these Java classes similar to JPA Entities? – Peter Penzov Jun 08 '17 at 21:27
  • @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? – Lukas Eder Jun 09 '17 at 07:41