From c5e9e49c213865ce657e9f7781acb3dd3d2cfb54 Mon Sep 17 00:00:00 2001 From: lukaseder Date: Tue, 23 May 2017 13:27:58 +0200 Subject: [PATCH] [#6005] Add DDLDatabase to reverse engineer DDL files --- .../resources/org/jooq/web/manual-3.10.xml | 115 +++++++++++++++++- .../resources/org/jooq/web/manual-3.6.xml | 4 +- .../resources/org/jooq/web/manual-3.7.xml | 4 +- .../resources/org/jooq/web/manual-3.8.xml | 4 +- .../resources/org/jooq/web/manual-3.9.xml | 4 +- .../java/org/jooq/util/ddl/DDLDatabase.java | 1 - 6 files changed, 121 insertions(+), 11 deletions(-) diff --git a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.10.xml b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.10.xml index 145cd3de44..675b79dda9 100644 --- a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.10.xml +++ b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.10.xml @@ -17417,7 +17417,7 @@ public class PostgresJSONGsonBinding implements Binding {
- Generating code from JPA annotated entities + JPADatabase: Code generation from entities

Many jOOQ users use jOOQ as a complementary SQL API in applications that mostly use JPA for their database interactions, e.g. to perform reporting, batch processing, analytics, etc. @@ -17530,7 +17530,7 @@ public class Book {

- Generating code from XML files + XMLDatabase: Code generation from XML files

By default, jOOQ's code generator takes live database connections as a database meta data source. In many project setups, this might not be optimal, as the live database is not always available. @@ -17667,6 +17667,117 @@ public class Book {

+
+ DDLDatabase: Code generation from SQL files + +

+ In many cases, the schema is defined in the form of a SQL script, which can be used with , or some other database migration tool. +

+ +

+ If you have a complete schema definition in a single file, or perhaps a set of incremental files that can reproduce your schema in any SQL dialect, then the DDLDatabase might be the right choice for you. It uses the internally and applies all your DDL increments to an in-memory H2 database, in order to produce a replica of your schema prior to reverse engineering it again using ordinary code generation. +

+ +

+ For example, the following database.sql script (the ) could be used: +

+ + + +

+ While the script uses pretty standard SQL constructs, you may well use some vendor-specific extensions, and even in between to set up your schema - it doesn't matter. You will simply need to set up your code generation configuration as follows: +

+ +

+ XML configuration (standalone and Maven) +

+ + + + + org.jooq.util.ddl.DDLDatabase + + + + + scripts + src/main/resources/database.sql + + + + +]]> + +

+ Programmatic configuration +

+ + + +

+ Gradle configuration +

+ + +
+
+
Running the code generator with Ant diff --git a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.6.xml b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.6.xml index db18d30376..e4055f61c9 100644 --- a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.6.xml +++ b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.6.xml @@ -14957,7 +14957,7 @@ public class PostgresJSONGsonBinding implements Binding {
- Generating code from JPA annotated entities + JPADatabase: Code generation from entities

Many jOOQ users use jOOQ as a complementary SQL API in applications that mostly use JPA for their database interactions, e.g. to perform reporting, batch processing, analytics, etc. @@ -15063,7 +15063,7 @@ public class Book {

- Generating code from XML files + XMLDatabase: Code generation from XML files

By default, jOOQ's code generator takes live database connections as a database meta data source. In many project setups, this might not be optimal, as the live database is not always available. diff --git a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.7.xml b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.7.xml index c7e6add083..1411d1117c 100644 --- a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.7.xml +++ b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.7.xml @@ -15374,7 +15374,7 @@ public class PostgresJSONGsonBinding implements Binding {

- Generating code from JPA annotated entities + JPADatabase: Code generation from entities

Many jOOQ users use jOOQ as a complementary SQL API in applications that mostly use JPA for their database interactions, e.g. to perform reporting, batch processing, analytics, etc. @@ -15487,7 +15487,7 @@ public class Book {

- Generating code from XML files + XMLDatabase: Code generation from XML files

By default, jOOQ's code generator takes live database connections as a database meta data source. In many project setups, this might not be optimal, as the live database is not always available. diff --git a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.8.xml b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.8.xml index 6ca897bcd1..76d7b6db5d 100644 --- a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.8.xml +++ b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.8.xml @@ -15647,7 +15647,7 @@ public class PostgresJSONGsonBinding implements Binding {

- Generating code from JPA annotated entities + JPADatabase: Code generation from entities

Many jOOQ users use jOOQ as a complementary SQL API in applications that mostly use JPA for their database interactions, e.g. to perform reporting, batch processing, analytics, etc. @@ -15760,7 +15760,7 @@ public class Book {

- Generating code from XML files + XMLDatabase: Code generation from XML files

By default, jOOQ's code generator takes live database connections as a database meta data source. In many project setups, this might not be optimal, as the live database is not always available. diff --git a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.9.xml b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.9.xml index ca937164e9..3603cac339 100644 --- a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.9.xml +++ b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.9.xml @@ -17244,7 +17244,7 @@ public class PostgresJSONGsonBinding implements Binding {

- Generating code from JPA annotated entities + JPADatabase: Code generation from entities

Many jOOQ users use jOOQ as a complementary SQL API in applications that mostly use JPA for their database interactions, e.g. to perform reporting, batch processing, analytics, etc. @@ -17357,7 +17357,7 @@ public class Book {

- Generating code from XML files + XMLDatabase: Code generation from XML files

By default, jOOQ's code generator takes live database connections as a database meta data source. In many project setups, this might not be optimal, as the live database is not always available. diff --git a/jOOQ-meta-extensions/src/main/java/org/jooq/util/ddl/DDLDatabase.java b/jOOQ-meta-extensions/src/main/java/org/jooq/util/ddl/DDLDatabase.java index d699dbcdc2..a95459a5e5 100644 --- a/jOOQ-meta-extensions/src/main/java/org/jooq/util/ddl/DDLDatabase.java +++ b/jOOQ-meta-extensions/src/main/java/org/jooq/util/ddl/DDLDatabase.java @@ -74,7 +74,6 @@ public class DDLDatabase extends H2Database { private Connection connection; - @SuppressWarnings("serial") @Override protected DSLContext create0() { if (connection == null) {