diff --git a/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/DefaultCatalog.java b/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/DefaultCatalog.java new file mode 100644 index 0000000000..3c9118bfad --- /dev/null +++ b/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/DefaultCatalog.java @@ -0,0 +1,60 @@ +/* + * This file is generated by jOOQ. + */ +package org.jooq.example.flyway.ddl.db.h2; + + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.annotation.processing.Generated; + +import org.jooq.Schema; +import org.jooq.impl.CatalogImpl; + + +/** + * This class is generated by jOOQ. + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.0-SNAPSHOT" + }, + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DefaultCatalog extends CatalogImpl { + + private static final long serialVersionUID = -846185862; + + /** + * The reference instance of + */ + public static final DefaultCatalog DEFAULT_CATALOG = new DefaultCatalog(); + + /** + * The schema FLYWAY_TEST. + */ + public final FlywayTest FLYWAY_TEST = org.jooq.example.flyway.ddl.db.h2.FlywayTest.FLYWAY_TEST; + + /** + * No further instances allowed + */ + private DefaultCatalog() { + super(""); + } + + @Override + public final List getSchemas() { + List result = new ArrayList(); + result.addAll(getSchemas0()); + return result; + } + + private final List getSchemas0() { + return Arrays.asList( + FlywayTest.FLYWAY_TEST); + } +} diff --git a/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/FlywayTest.java b/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/FlywayTest.java new file mode 100644 index 0000000000..f09a8e496e --- /dev/null +++ b/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/FlywayTest.java @@ -0,0 +1,88 @@ +/* + * This file is generated by jOOQ. + */ +package org.jooq.example.flyway.ddl.db.h2; + + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.annotation.processing.Generated; + +import org.jooq.Catalog; +import org.jooq.Sequence; +import org.jooq.Table; +import org.jooq.example.flyway.ddl.db.h2.tables.Author; +import org.jooq.example.flyway.ddl.db.h2.tables.Book; +import org.jooq.impl.SchemaImpl; + + +/** + * This class is generated by jOOQ. + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.0-SNAPSHOT" + }, + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class FlywayTest extends SchemaImpl { + + private static final long serialVersionUID = -520771476; + + /** + * The reference instance of FLYWAY_TEST + */ + public static final FlywayTest FLYWAY_TEST = new FlywayTest(); + + /** + * The table FLYWAY_TEST.AUTHOR. + */ + public final Author AUTHOR = org.jooq.example.flyway.ddl.db.h2.tables.Author.AUTHOR; + + /** + * The table FLYWAY_TEST.BOOK. + */ + public final Book BOOK = org.jooq.example.flyway.ddl.db.h2.tables.Book.BOOK; + + /** + * No further instances allowed + */ + private FlywayTest() { + super("FLYWAY_TEST", null); + } + + + @Override + public Catalog getCatalog() { + return DefaultCatalog.DEFAULT_CATALOG; + } + + @Override + public final List> getSequences() { + List result = new ArrayList(); + result.addAll(getSequences0()); + return result; + } + + private final List> getSequences0() { + return Arrays.>asList( + Sequences.S_AUTHOR_ID); + } + + @Override + public final List> getTables() { + List result = new ArrayList(); + result.addAll(getTables0()); + return result; + } + + private final List> getTables0() { + return Arrays.>asList( + Author.AUTHOR, + Book.BOOK); + } +} diff --git a/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/Indexes.java b/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/Indexes.java new file mode 100644 index 0000000000..1781f4dced --- /dev/null +++ b/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/Indexes.java @@ -0,0 +1,46 @@ +/* + * This file is generated by jOOQ. + */ +package org.jooq.example.flyway.ddl.db.h2; + + +import javax.annotation.processing.Generated; + +import org.jooq.Index; +import org.jooq.OrderField; +import org.jooq.example.flyway.ddl.db.h2.tables.Author; +import org.jooq.example.flyway.ddl.db.h2.tables.Book; +import org.jooq.impl.Internal; + + +/** + * A class modelling indexes of tables of the FLYWAY_TEST schema. + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.0-SNAPSHOT" + }, + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class Indexes { + + // ------------------------------------------------------------------------- + // INDEX definitions + // ------------------------------------------------------------------------- + + public static final Index PRIMARY_KEY_7 = Indexes0.PRIMARY_KEY_7; + public static final Index FK_T_BOOK_AUTHOR_ID_INDEX_1 = Indexes0.FK_T_BOOK_AUTHOR_ID_INDEX_1; + public static final Index PRIMARY_KEY_1 = Indexes0.PRIMARY_KEY_1; + + // ------------------------------------------------------------------------- + // [#1459] distribute members to avoid static initialisers > 64kb + // ------------------------------------------------------------------------- + + private static class Indexes0 { + public static Index PRIMARY_KEY_7 = Internal.createIndex("PRIMARY_KEY_7", Author.AUTHOR, new OrderField[] { Author.AUTHOR.ID }, true); + public static Index FK_T_BOOK_AUTHOR_ID_INDEX_1 = Internal.createIndex("FK_T_BOOK_AUTHOR_ID_INDEX_1", Book.BOOK, new OrderField[] { Book.BOOK.AUTHOR_ID }, false); + public static Index PRIMARY_KEY_1 = Internal.createIndex("PRIMARY_KEY_1", Book.BOOK, new OrderField[] { Book.BOOK.ID }, true); + } +} diff --git a/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/Keys.java b/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/Keys.java new file mode 100644 index 0000000000..31ba0c9b32 --- /dev/null +++ b/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/Keys.java @@ -0,0 +1,62 @@ +/* + * This file is generated by jOOQ. + */ +package org.jooq.example.flyway.ddl.db.h2; + + +import javax.annotation.processing.Generated; + +import org.jooq.ForeignKey; +import org.jooq.UniqueKey; +import org.jooq.example.flyway.ddl.db.h2.tables.Author; +import org.jooq.example.flyway.ddl.db.h2.tables.Book; +import org.jooq.example.flyway.ddl.db.h2.tables.records.AuthorRecord; +import org.jooq.example.flyway.ddl.db.h2.tables.records.BookRecord; +import org.jooq.impl.Internal; + + +/** + * A class modelling foreign key relationships and constraints of tables of + * the FLYWAY_TEST schema. + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.0-SNAPSHOT" + }, + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class Keys { + + // ------------------------------------------------------------------------- + // IDENTITY definitions + // ------------------------------------------------------------------------- + + + // ------------------------------------------------------------------------- + // UNIQUE and PRIMARY KEY definitions + // ------------------------------------------------------------------------- + + public static final UniqueKey PK_T_AUTHOR = UniqueKeys0.PK_T_AUTHOR; + public static final UniqueKey PK_T_BOOK = UniqueKeys0.PK_T_BOOK; + + // ------------------------------------------------------------------------- + // FOREIGN KEY definitions + // ------------------------------------------------------------------------- + + public static final ForeignKey FK_T_BOOK_AUTHOR_ID = ForeignKeys0.FK_T_BOOK_AUTHOR_ID; + + // ------------------------------------------------------------------------- + // [#1459] distribute members to avoid static initialisers > 64kb + // ------------------------------------------------------------------------- + + private static class UniqueKeys0 { + public static final UniqueKey PK_T_AUTHOR = Internal.createUniqueKey(Author.AUTHOR, "PK_T_AUTHOR", Author.AUTHOR.ID); + public static final UniqueKey PK_T_BOOK = Internal.createUniqueKey(Book.BOOK, "PK_T_BOOK", Book.BOOK.ID); + } + + private static class ForeignKeys0 { + public static final ForeignKey FK_T_BOOK_AUTHOR_ID = Internal.createForeignKey(org.jooq.example.flyway.ddl.db.h2.Keys.PK_T_AUTHOR, Book.BOOK, "FK_T_BOOK_AUTHOR_ID", Book.BOOK.AUTHOR_ID); + } +} diff --git a/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/Sequences.java b/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/Sequences.java new file mode 100644 index 0000000000..246af6a4fc --- /dev/null +++ b/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/Sequences.java @@ -0,0 +1,30 @@ +/* + * This file is generated by jOOQ. + */ +package org.jooq.example.flyway.ddl.db.h2; + + +import javax.annotation.processing.Generated; + +import org.jooq.Sequence; +import org.jooq.impl.SequenceImpl; + + +/** + * Convenience access to all sequences in FLYWAY_TEST + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.0-SNAPSHOT" + }, + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class Sequences { + + /** + * The sequence FLYWAY_TEST.S_AUTHOR_ID + */ + public static final Sequence S_AUTHOR_ID = new SequenceImpl("S_AUTHOR_ID", FlywayTest.FLYWAY_TEST, org.jooq.impl.SQLDataType.BIGINT); +} diff --git a/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/Tables.java b/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/Tables.java new file mode 100644 index 0000000000..93fc3c4775 --- /dev/null +++ b/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/Tables.java @@ -0,0 +1,35 @@ +/* + * This file is generated by jOOQ. + */ +package org.jooq.example.flyway.ddl.db.h2; + + +import javax.annotation.processing.Generated; + +import org.jooq.example.flyway.ddl.db.h2.tables.Author; +import org.jooq.example.flyway.ddl.db.h2.tables.Book; + + +/** + * Convenience access to all tables in FLYWAY_TEST + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.0-SNAPSHOT" + }, + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class Tables { + + /** + * The table FLYWAY_TEST.AUTHOR. + */ + public static final Author AUTHOR = Author.AUTHOR; + + /** + * The table FLYWAY_TEST.BOOK. + */ + public static final Book BOOK = Book.BOOK; +} diff --git a/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/tables/Author.java b/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/tables/Author.java new file mode 100644 index 0000000000..d36403a098 --- /dev/null +++ b/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/tables/Author.java @@ -0,0 +1,176 @@ +/* + * This file is generated by jOOQ. + */ +package org.jooq.example.flyway.ddl.db.h2.tables; + + +import java.sql.Date; +import java.util.Arrays; +import java.util.List; + +import javax.annotation.processing.Generated; + +import org.jooq.Field; +import org.jooq.ForeignKey; +import org.jooq.Index; +import org.jooq.Name; +import org.jooq.Record; +import org.jooq.Row6; +import org.jooq.Schema; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.UniqueKey; +import org.jooq.example.flyway.ddl.db.h2.FlywayTest; +import org.jooq.example.flyway.ddl.db.h2.Indexes; +import org.jooq.example.flyway.ddl.db.h2.Keys; +import org.jooq.example.flyway.ddl.db.h2.tables.records.AuthorRecord; +import org.jooq.impl.DSL; +import org.jooq.impl.TableImpl; + + +/** + * This class is generated by jOOQ. + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.0-SNAPSHOT" + }, + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class Author extends TableImpl { + + private static final long serialVersionUID = 1689383333; + + /** + * The reference instance of FLYWAY_TEST.AUTHOR + */ + public static final Author AUTHOR = new Author(); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return AuthorRecord.class; + } + + /** + * The column FLYWAY_TEST.AUTHOR.ID. + */ + public final TableField ID = createField(DSL.name("ID"), org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column FLYWAY_TEST.AUTHOR.FIRST_NAME. + */ + public final TableField FIRST_NAME = createField(DSL.name("FIRST_NAME"), org.jooq.impl.SQLDataType.VARCHAR(50), this, ""); + + /** + * The column FLYWAY_TEST.AUTHOR.LAST_NAME. + */ + public final TableField LAST_NAME = createField(DSL.name("LAST_NAME"), org.jooq.impl.SQLDataType.VARCHAR(50).nullable(false), this, ""); + + /** + * The column FLYWAY_TEST.AUTHOR.DATE_OF_BIRTH. + */ + public final TableField DATE_OF_BIRTH = createField(DSL.name("DATE_OF_BIRTH"), org.jooq.impl.SQLDataType.DATE, this, ""); + + /** + * The column FLYWAY_TEST.AUTHOR.YEAR_OF_BIRTH. + */ + public final TableField YEAR_OF_BIRTH = createField(DSL.name("YEAR_OF_BIRTH"), org.jooq.impl.SQLDataType.INTEGER, this, ""); + + /** + * The column FLYWAY_TEST.AUTHOR.ADDRESS. + */ + public final TableField ADDRESS = createField(DSL.name("ADDRESS"), org.jooq.impl.SQLDataType.VARCHAR(50), this, ""); + + /** + * Create a FLYWAY_TEST.AUTHOR table reference + */ + public Author() { + this(DSL.name("AUTHOR"), null); + } + + /** + * Create an aliased FLYWAY_TEST.AUTHOR table reference + */ + public Author(String alias) { + this(DSL.name(alias), AUTHOR); + } + + /** + * Create an aliased FLYWAY_TEST.AUTHOR table reference + */ + public Author(Name alias) { + this(alias, AUTHOR); + } + + private Author(Name alias, Table aliased) { + this(alias, aliased, null); + } + + private Author(Name alias, Table aliased, Field[] parameters) { + super(alias, null, aliased, parameters, DSL.comment("")); + } + + public Author(Table child, ForeignKey key) { + super(child, key, AUTHOR); + } + + @Override + public Schema getSchema() { + return FlywayTest.FLYWAY_TEST; + } + + @Override + public List getIndexes() { + return Arrays.asList(Indexes.PRIMARY_KEY_7); + } + + @Override + public UniqueKey getPrimaryKey() { + return Keys.PK_T_AUTHOR; + } + + @Override + public List> getKeys() { + return Arrays.>asList(Keys.PK_T_AUTHOR); + } + + @Override + public Author as(String alias) { + return new Author(DSL.name(alias), this); + } + + @Override + public Author as(Name alias) { + return new Author(alias, this); + } + + /** + * Rename this table + */ + @Override + public Author rename(String name) { + return new Author(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public Author rename(Name name) { + return new Author(name, null); + } + + // ------------------------------------------------------------------------- + // Row6 type methods + // ------------------------------------------------------------------------- + + @Override + public Row6 fieldsRow() { + return (Row6) super.fieldsRow(); + } +} diff --git a/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/tables/Book.java b/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/tables/Book.java new file mode 100644 index 0000000000..3da52f6cde --- /dev/null +++ b/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/tables/Book.java @@ -0,0 +1,169 @@ +/* + * This file is generated by jOOQ. + */ +package org.jooq.example.flyway.ddl.db.h2.tables; + + +import java.util.Arrays; +import java.util.List; + +import javax.annotation.processing.Generated; + +import org.jooq.Field; +import org.jooq.ForeignKey; +import org.jooq.Index; +import org.jooq.Name; +import org.jooq.Record; +import org.jooq.Row3; +import org.jooq.Schema; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.UniqueKey; +import org.jooq.example.flyway.ddl.db.h2.FlywayTest; +import org.jooq.example.flyway.ddl.db.h2.Indexes; +import org.jooq.example.flyway.ddl.db.h2.Keys; +import org.jooq.example.flyway.ddl.db.h2.tables.records.BookRecord; +import org.jooq.impl.DSL; +import org.jooq.impl.TableImpl; + + +/** + * This class is generated by jOOQ. + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.0-SNAPSHOT" + }, + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class Book extends TableImpl { + + private static final long serialVersionUID = 353140781; + + /** + * The reference instance of FLYWAY_TEST.BOOK + */ + public static final Book BOOK = new Book(); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return BookRecord.class; + } + + /** + * The column FLYWAY_TEST.BOOK.ID. + */ + public final TableField ID = createField(DSL.name("ID"), org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column FLYWAY_TEST.BOOK.AUTHOR_ID. + */ + public final TableField AUTHOR_ID = createField(DSL.name("AUTHOR_ID"), org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column FLYWAY_TEST.BOOK.TITLE. + */ + public final TableField TITLE = createField(DSL.name("TITLE"), org.jooq.impl.SQLDataType.VARCHAR(400).nullable(false), this, ""); + + /** + * Create a FLYWAY_TEST.BOOK table reference + */ + public Book() { + this(DSL.name("BOOK"), null); + } + + /** + * Create an aliased FLYWAY_TEST.BOOK table reference + */ + public Book(String alias) { + this(DSL.name(alias), BOOK); + } + + /** + * Create an aliased FLYWAY_TEST.BOOK table reference + */ + public Book(Name alias) { + this(alias, BOOK); + } + + private Book(Name alias, Table aliased) { + this(alias, aliased, null); + } + + private Book(Name alias, Table aliased, Field[] parameters) { + super(alias, null, aliased, parameters, DSL.comment("")); + } + + public Book(Table child, ForeignKey key) { + super(child, key, BOOK); + } + + @Override + public Schema getSchema() { + return FlywayTest.FLYWAY_TEST; + } + + @Override + public List getIndexes() { + return Arrays.asList(Indexes.FK_T_BOOK_AUTHOR_ID_INDEX_1, Indexes.PRIMARY_KEY_1); + } + + @Override + public UniqueKey getPrimaryKey() { + return Keys.PK_T_BOOK; + } + + @Override + public List> getKeys() { + return Arrays.>asList(Keys.PK_T_BOOK); + } + + @Override + public List> getReferences() { + return Arrays.>asList(Keys.FK_T_BOOK_AUTHOR_ID); + } + + public Author author() { + return new Author(this, Keys.FK_T_BOOK_AUTHOR_ID); + } + + @Override + public Book as(String alias) { + return new Book(DSL.name(alias), this); + } + + @Override + public Book as(Name alias) { + return new Book(alias, this); + } + + /** + * Rename this table + */ + @Override + public Book rename(String name) { + return new Book(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public Book rename(Name name) { + return new Book(name, null); + } + + // ------------------------------------------------------------------------- + // Row3 type methods + // ------------------------------------------------------------------------- + + @Override + public Row3 fieldsRow() { + return (Row3) super.fieldsRow(); + } +} diff --git a/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/tables/records/AuthorRecord.java b/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/tables/records/AuthorRecord.java new file mode 100644 index 0000000000..ecaa597f9d --- /dev/null +++ b/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/tables/records/AuthorRecord.java @@ -0,0 +1,302 @@ +/* + * This file is generated by jOOQ. + */ +package org.jooq.example.flyway.ddl.db.h2.tables.records; + + +import java.sql.Date; + +import javax.annotation.processing.Generated; + +import org.jooq.Field; +import org.jooq.Record1; +import org.jooq.Record6; +import org.jooq.Row6; +import org.jooq.example.flyway.ddl.db.h2.tables.Author; +import org.jooq.impl.UpdatableRecordImpl; + + +/** + * This class is generated by jOOQ. + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.0-SNAPSHOT" + }, + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class AuthorRecord extends UpdatableRecordImpl implements Record6 { + + private static final long serialVersionUID = -850705131; + + /** + * Setter for FLYWAY_TEST.AUTHOR.ID. + */ + public void setId(Integer value) { + set(0, value); + } + + /** + * Getter for FLYWAY_TEST.AUTHOR.ID. + */ + public Integer getId() { + return (Integer) get(0); + } + + /** + * Setter for FLYWAY_TEST.AUTHOR.FIRST_NAME. + */ + public void setFirstName(String value) { + set(1, value); + } + + /** + * Getter for FLYWAY_TEST.AUTHOR.FIRST_NAME. + */ + public String getFirstName() { + return (String) get(1); + } + + /** + * Setter for FLYWAY_TEST.AUTHOR.LAST_NAME. + */ + public void setLastName(String value) { + set(2, value); + } + + /** + * Getter for FLYWAY_TEST.AUTHOR.LAST_NAME. + */ + public String getLastName() { + return (String) get(2); + } + + /** + * Setter for FLYWAY_TEST.AUTHOR.DATE_OF_BIRTH. + */ + public void setDateOfBirth(Date value) { + set(3, value); + } + + /** + * Getter for FLYWAY_TEST.AUTHOR.DATE_OF_BIRTH. + */ + public Date getDateOfBirth() { + return (Date) get(3); + } + + /** + * Setter for FLYWAY_TEST.AUTHOR.YEAR_OF_BIRTH. + */ + public void setYearOfBirth(Integer value) { + set(4, value); + } + + /** + * Getter for FLYWAY_TEST.AUTHOR.YEAR_OF_BIRTH. + */ + public Integer getYearOfBirth() { + return (Integer) get(4); + } + + /** + * Setter for FLYWAY_TEST.AUTHOR.ADDRESS. + */ + public void setAddress(String value) { + set(5, value); + } + + /** + * Getter for FLYWAY_TEST.AUTHOR.ADDRESS. + */ + public String getAddress() { + return (String) get(5); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record6 type implementation + // ------------------------------------------------------------------------- + + @Override + public Row6 fieldsRow() { + return (Row6) super.fieldsRow(); + } + + @Override + public Row6 valuesRow() { + return (Row6) super.valuesRow(); + } + + @Override + public Field field1() { + return Author.AUTHOR.ID; + } + + @Override + public Field field2() { + return Author.AUTHOR.FIRST_NAME; + } + + @Override + public Field field3() { + return Author.AUTHOR.LAST_NAME; + } + + @Override + public Field field4() { + return Author.AUTHOR.DATE_OF_BIRTH; + } + + @Override + public Field field5() { + return Author.AUTHOR.YEAR_OF_BIRTH; + } + + @Override + public Field field6() { + return Author.AUTHOR.ADDRESS; + } + + @Override + public Integer component1() { + return getId(); + } + + @Override + public String component2() { + return getFirstName(); + } + + @Override + public String component3() { + return getLastName(); + } + + @Override + public Date component4() { + return getDateOfBirth(); + } + + @Override + public Integer component5() { + return getYearOfBirth(); + } + + @Override + public String component6() { + return getAddress(); + } + + @Override + public Integer value1() { + return getId(); + } + + @Override + public String value2() { + return getFirstName(); + } + + @Override + public String value3() { + return getLastName(); + } + + @Override + public Date value4() { + return getDateOfBirth(); + } + + @Override + public Integer value5() { + return getYearOfBirth(); + } + + @Override + public String value6() { + return getAddress(); + } + + @Override + public AuthorRecord value1(Integer value) { + setId(value); + return this; + } + + @Override + public AuthorRecord value2(String value) { + setFirstName(value); + return this; + } + + @Override + public AuthorRecord value3(String value) { + setLastName(value); + return this; + } + + @Override + public AuthorRecord value4(Date value) { + setDateOfBirth(value); + return this; + } + + @Override + public AuthorRecord value5(Integer value) { + setYearOfBirth(value); + return this; + } + + @Override + public AuthorRecord value6(String value) { + setAddress(value); + return this; + } + + @Override + public AuthorRecord values(Integer value1, String value2, String value3, Date value4, Integer value5, String value6) { + value1(value1); + value2(value2); + value3(value3); + value4(value4); + value5(value5); + value6(value6); + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached AuthorRecord + */ + public AuthorRecord() { + super(Author.AUTHOR); + } + + /** + * Create a detached, initialised AuthorRecord + */ + public AuthorRecord(Integer id, String firstName, String lastName, Date dateOfBirth, Integer yearOfBirth, String address) { + super(Author.AUTHOR); + + set(0, id); + set(1, firstName); + set(2, lastName); + set(3, dateOfBirth); + set(4, yearOfBirth); + set(5, address); + } +} diff --git a/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/tables/records/BookRecord.java b/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/tables/records/BookRecord.java new file mode 100644 index 0000000000..82b8b08efc --- /dev/null +++ b/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/java/org/jooq/example/flyway/ddl/db/h2/tables/records/BookRecord.java @@ -0,0 +1,189 @@ +/* + * This file is generated by jOOQ. + */ +package org.jooq.example.flyway.ddl.db.h2.tables.records; + + +import javax.annotation.processing.Generated; + +import org.jooq.Field; +import org.jooq.Record1; +import org.jooq.Record3; +import org.jooq.Row3; +import org.jooq.example.flyway.ddl.db.h2.tables.Book; +import org.jooq.impl.UpdatableRecordImpl; + + +/** + * This class is generated by jOOQ. + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.0-SNAPSHOT" + }, + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class BookRecord extends UpdatableRecordImpl implements Record3 { + + private static final long serialVersionUID = 789103786; + + /** + * Setter for FLYWAY_TEST.BOOK.ID. + */ + public void setId(Integer value) { + set(0, value); + } + + /** + * Getter for FLYWAY_TEST.BOOK.ID. + */ + public Integer getId() { + return (Integer) get(0); + } + + /** + * Setter for FLYWAY_TEST.BOOK.AUTHOR_ID. + */ + public void setAuthorId(Integer value) { + set(1, value); + } + + /** + * Getter for FLYWAY_TEST.BOOK.AUTHOR_ID. + */ + public Integer getAuthorId() { + return (Integer) get(1); + } + + /** + * Setter for FLYWAY_TEST.BOOK.TITLE. + */ + public void setTitle(String value) { + set(2, value); + } + + /** + * Getter for FLYWAY_TEST.BOOK.TITLE. + */ + public String getTitle() { + return (String) get(2); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record3 type implementation + // ------------------------------------------------------------------------- + + @Override + public Row3 fieldsRow() { + return (Row3) super.fieldsRow(); + } + + @Override + public Row3 valuesRow() { + return (Row3) super.valuesRow(); + } + + @Override + public Field field1() { + return Book.BOOK.ID; + } + + @Override + public Field field2() { + return Book.BOOK.AUTHOR_ID; + } + + @Override + public Field field3() { + return Book.BOOK.TITLE; + } + + @Override + public Integer component1() { + return getId(); + } + + @Override + public Integer component2() { + return getAuthorId(); + } + + @Override + public String component3() { + return getTitle(); + } + + @Override + public Integer value1() { + return getId(); + } + + @Override + public Integer value2() { + return getAuthorId(); + } + + @Override + public String value3() { + return getTitle(); + } + + @Override + public BookRecord value1(Integer value) { + setId(value); + return this; + } + + @Override + public BookRecord value2(Integer value) { + setAuthorId(value); + return this; + } + + @Override + public BookRecord value3(String value) { + setTitle(value); + return this; + } + + @Override + public BookRecord values(Integer value1, Integer value2, String value3) { + value1(value1); + value2(value2); + value3(value3); + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached BookRecord + */ + public BookRecord() { + super(Book.BOOK); + } + + /** + * Create a detached, initialised BookRecord + */ + public BookRecord(Integer id, Integer authorId, String title) { + super(Book.BOOK); + + set(0, id); + set(1, authorId); + set(2, title); + } +} diff --git a/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/resources/db/migration/V1.04__insert_data.sql b/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/resources/db/migration/V1.04__insert_data.sql new file mode 100644 index 0000000000..cfe206feae --- /dev/null +++ b/jOOQ-examples/jOOQ-flyway-ddl-example/src/main/resources/db/migration/V1.04__insert_data.sql @@ -0,0 +1,7 @@ +INSERT INTO flyway_test.author VALUES (next value for flyway_test.s_author_id, 'George', 'Orwell', '1903-06-25', 1903, null); +INSERT INTO flyway_test.author VALUES (next value for flyway_test.s_author_id, 'Paulo', 'Coelho', '1947-08-24', 1947, null); + +INSERT INTO flyway_test.book VALUES (1, 1, '1984'); +INSERT INTO flyway_test.book VALUES (2, 1, 'Animal Farm'); +INSERT INTO flyway_test.book VALUES (3, 2, 'O Alquimista'); +INSERT INTO flyway_test.book VALUES (4, 2, 'Brida'); \ No newline at end of file diff --git a/jOOQ-examples/jOOQ-flyway-ddl-example/src/test/java/org/jooq/example/flyway/ddl/FlywayTest.java b/jOOQ-examples/jOOQ-flyway-ddl-example/src/test/java/org/jooq/example/flyway/ddl/FlywayTest.java new file mode 100644 index 0000000000..46b943cc92 --- /dev/null +++ b/jOOQ-examples/jOOQ-flyway-ddl-example/src/test/java/org/jooq/example/flyway/ddl/FlywayTest.java @@ -0,0 +1,60 @@ +package org.jooq.example.flyway.ddl; + +import static java.util.Arrays.asList; +import static org.jooq.example.flyway.ddl.db.h2.Tables.AUTHOR; +import static org.jooq.example.flyway.ddl.db.h2.Tables.BOOK; +import static org.junit.Assert.assertEquals; + +import java.sql.Connection; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.Properties; +import java.util.UUID; + +import org.flywaydb.core.Flyway; +import org.jooq.Record3; +import org.jooq.Result; +import org.jooq.impl.DSL; +import org.jooq.tools.jdbc.SingleConnectionDataSource; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class FlywayTest { + + private Connection connection; + + @Before + public void setup() throws SQLException { + Properties info = new Properties(); + info.put("user", "sa"); + info.put("password", ""); + connection = new org.h2.Driver().connect("jdbc:h2:mem:jooq-example-flyway-ddl-" + UUID.randomUUID(), info); + + // This flyway migration should produce the same database as the DDLDatabase + // used by the code generator, as it is configured using flyway file sorting + Flyway flyway = Flyway.configure().dataSource(new SingleConnectionDataSource(connection)).load(); + flyway.migrate(); + } + + @After + public void teardown() throws SQLException { + connection.close(); + } + + @Test + public void test() { + Result> result = + DSL.using(connection) + .select(AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME, BOOK.TITLE) + .from(AUTHOR) + .join(BOOK).on(AUTHOR.ID.eq(BOOK.AUTHOR_ID)) + .orderBy(AUTHOR.ID, BOOK.ID) + .fetch(); + + assertEquals(4, result.size()); + assertEquals(asList("George", "George", "Paulo", "Paulo"), result.getValues(AUTHOR.FIRST_NAME)); + assertEquals(asList("Orwell", "Orwell", "Coelho", "Coelho"), result.getValues(AUTHOR.LAST_NAME)); + assertEquals(asList("1984", "Animal Farm", "O Alquimista", "Brida"), result.getValues(BOOK.TITLE)); + } +}