Bael 7668 (#16257)
* BAEL-7490 read write file in separate thread * Change the to try resources * Update the code to sync with article * jooq join table * Fix the wildcard import
This commit is contained in:
parent
f8fe72540d
commit
8e247e172b
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This file is generated by jOOQ.
|
||||
*/
|
||||
package com.baeldung.jooq.jointables;
|
||||
|
||||
|
||||
import com.baeldung.jooq.jointables.public_.Public;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.jooq.Constants;
|
||||
import org.jooq.Schema;
|
||||
import org.jooq.impl.CatalogImpl;
|
||||
|
||||
|
||||
/**
|
||||
* This class is generated by jOOQ.
|
||||
*/
|
||||
@SuppressWarnings({ "all", "unchecked", "rawtypes", "this-escape" })
|
||||
public class DefaultCatalog extends CatalogImpl {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* The reference instance of <code>DEFAULT_CATALOG</code>
|
||||
*/
|
||||
public static final DefaultCatalog DEFAULT_CATALOG = new DefaultCatalog();
|
||||
|
||||
/**
|
||||
* The schema <code>public</code>.
|
||||
*/
|
||||
public final Public PUBLIC = Public.PUBLIC;
|
||||
|
||||
/**
|
||||
* No further instances allowed
|
||||
*/
|
||||
private DefaultCatalog() {
|
||||
super("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Schema> getSchemas() {
|
||||
return Arrays.asList(
|
||||
Public.PUBLIC
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* A reference to the 3.19 minor release of the code generator. If this
|
||||
* doesn't compile, it's because the runtime library uses an older minor
|
||||
* release, namely: 3.19. You can turn off the generation of this reference
|
||||
* by specifying /configuration/generator/generate/jooqVersionReference
|
||||
*/
|
||||
private static final String REQUIRE_RUNTIME_JOOQ_VERSION = Constants.VERSION_3_19;
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package com.baeldung.jooq.jointables;
|
||||
|
||||
import static org.jooq.impl.DSL.field;
|
||||
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.Result;
|
||||
import org.jooq.SelectJoinStep;
|
||||
|
||||
import com.baeldung.jooq.jointables.public_.Tables;
|
||||
|
||||
public class JoinTables {
|
||||
|
||||
public static Result<Record> usingJoinMethod(DSLContext context) {
|
||||
SelectJoinStep<Record> query = context.select()
|
||||
.from(Tables.BOOK)
|
||||
.join(Tables.BOOKAUTHOR)
|
||||
.on(field(Tables.BOOK.AUTHOR_ID).eq(field(Tables.BOOKAUTHOR.ID)));
|
||||
return query.fetch();
|
||||
}
|
||||
|
||||
public static Result<Record> usingMultipleJoinMethod(DSLContext context) {
|
||||
SelectJoinStep<Record> query = context.select()
|
||||
.from(Tables.BOOK)
|
||||
.join(Tables.BOOKAUTHOR)
|
||||
.on(field(Tables.BOOK.AUTHOR_ID).eq(field(Tables.BOOKAUTHOR.ID)))
|
||||
.join(Tables.STORE)
|
||||
.on(field(Tables.BOOK.STORE_ID).eq(field(Tables.STORE.ID)));
|
||||
return query.fetch();
|
||||
}
|
||||
|
||||
public static Result<Record> usingLeftOuterJoinMethod(DSLContext context) {
|
||||
SelectJoinStep<Record> query = context.select()
|
||||
.from(Tables.BOOK)
|
||||
.leftOuterJoin(Tables.BOOKAUTHOR)
|
||||
.on(field(Tables.BOOK.AUTHOR_ID).eq(field(Tables.BOOKAUTHOR.ID)));
|
||||
return query.fetch();
|
||||
}
|
||||
|
||||
public static Result<Record> usingRightOuterJoinMethod(DSLContext context) {
|
||||
SelectJoinStep<Record> query = context.select()
|
||||
.from(Tables.BOOK)
|
||||
.rightOuterJoin(Tables.BOOKAUTHOR)
|
||||
.on(field(Tables.BOOK.AUTHOR_ID).eq(field(Tables.BOOKAUTHOR.ID)));
|
||||
return query.fetch();
|
||||
}
|
||||
|
||||
public static Result<Record> usingFullOuterJoinMethod(DSLContext context) {
|
||||
SelectJoinStep<Record> query = context.select()
|
||||
.from(Tables.BOOK)
|
||||
.fullOuterJoin(Tables.BOOKAUTHOR)
|
||||
.on(field(Tables.BOOK.AUTHOR_ID).eq(field(Tables.BOOKAUTHOR.ID)));
|
||||
return query.fetch();
|
||||
}
|
||||
|
||||
public static Result<Record> usingNaturalJoinMethod(DSLContext context) {
|
||||
SelectJoinStep<Record> query = context.select()
|
||||
.from(Tables.BOOK)
|
||||
.naturalJoin(Tables.BOOKAUTHOR);
|
||||
return query.fetch();
|
||||
}
|
||||
|
||||
public static Result<Record> usingCrossJoinMethod(DSLContext context) {
|
||||
SelectJoinStep<Record> query = context.select()
|
||||
.from(Tables.STORE)
|
||||
.crossJoin(Tables.BOOK);
|
||||
return query.fetch();
|
||||
}
|
||||
|
||||
public static void printResult(Result<Record> result) {
|
||||
for (Record record : result) {
|
||||
System.out.println(record);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is generated by jOOQ.
|
||||
*/
|
||||
package com.baeldung.jooq.jointables.public_;
|
||||
|
||||
|
||||
import com.baeldung.jooq.jointables.public_.tables.Book;
|
||||
import com.baeldung.jooq.jointables.public_.tables.Bookauthor;
|
||||
import com.baeldung.jooq.jointables.public_.tables.Store;
|
||||
import com.baeldung.jooq.jointables.public_.tables.records.BookRecord;
|
||||
import com.baeldung.jooq.jointables.public_.tables.records.BookauthorRecord;
|
||||
import com.baeldung.jooq.jointables.public_.tables.records.StoreRecord;
|
||||
|
||||
import org.jooq.TableField;
|
||||
import org.jooq.UniqueKey;
|
||||
import org.jooq.impl.DSL;
|
||||
import org.jooq.impl.Internal;
|
||||
|
||||
|
||||
/**
|
||||
* A class modelling foreign key relationships and constraints of tables in
|
||||
* public.
|
||||
*/
|
||||
@SuppressWarnings({ "all", "unchecked", "rawtypes", "this-escape" })
|
||||
public class Keys {
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// UNIQUE and PRIMARY KEY definitions
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
public static final UniqueKey<BookRecord> BOOK_PKEY = Internal.createUniqueKey(Book.BOOK, DSL.name("Book_pkey"), new TableField[] { Book.BOOK.ID }, true);
|
||||
public static final UniqueKey<BookauthorRecord> AUTHOR_PKEY = Internal.createUniqueKey(Bookauthor.BOOKAUTHOR, DSL.name("Author_pkey"), new TableField[] { Bookauthor.BOOKAUTHOR.ID }, true);
|
||||
public static final UniqueKey<StoreRecord> STORE_PKEY = Internal.createUniqueKey(Store.STORE, DSL.name("Store_pkey"), new TableField[] { Store.STORE.ID }, true);
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* This file is generated by jOOQ.
|
||||
*/
|
||||
package com.baeldung.jooq.jointables.public_;
|
||||
|
||||
|
||||
import com.baeldung.jooq.jointables.DefaultCatalog;
|
||||
import com.baeldung.jooq.jointables.public_.tables.Book;
|
||||
import com.baeldung.jooq.jointables.public_.tables.Bookauthor;
|
||||
import com.baeldung.jooq.jointables.public_.tables.Store;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.jooq.Catalog;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.impl.SchemaImpl;
|
||||
|
||||
|
||||
/**
|
||||
* This class is generated by jOOQ.
|
||||
*/
|
||||
@SuppressWarnings({ "all", "unchecked", "rawtypes", "this-escape" })
|
||||
public class Public extends SchemaImpl {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* The reference instance of <code>public</code>
|
||||
*/
|
||||
public static final Public PUBLIC = new Public();
|
||||
|
||||
/**
|
||||
* The table <code>public.Book</code>.
|
||||
*/
|
||||
public final Book BOOK = Book.BOOK;
|
||||
|
||||
/**
|
||||
* The table <code>public.BookAuthor</code>.
|
||||
*/
|
||||
public final Bookauthor BOOKAUTHOR = Bookauthor.BOOKAUTHOR;
|
||||
|
||||
/**
|
||||
* The table <code>public.Store</code>.
|
||||
*/
|
||||
public final Store STORE = Store.STORE;
|
||||
|
||||
/**
|
||||
* No further instances allowed
|
||||
*/
|
||||
private Public() {
|
||||
super("public", null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Catalog getCatalog() {
|
||||
return DefaultCatalog.DEFAULT_CATALOG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Table<?>> getTables() {
|
||||
return Arrays.asList(
|
||||
Book.BOOK,
|
||||
Bookauthor.BOOKAUTHOR,
|
||||
Store.STORE
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* This file is generated by jOOQ.
|
||||
*/
|
||||
package com.baeldung.jooq.jointables.public_;
|
||||
|
||||
|
||||
import com.baeldung.jooq.jointables.public_.tables.Book;
|
||||
import com.baeldung.jooq.jointables.public_.tables.Bookauthor;
|
||||
import com.baeldung.jooq.jointables.public_.tables.Store;
|
||||
|
||||
|
||||
/**
|
||||
* Convenience access to all tables in public.
|
||||
*/
|
||||
@SuppressWarnings({ "all", "unchecked", "rawtypes", "this-escape" })
|
||||
public class Tables {
|
||||
|
||||
/**
|
||||
* The table <code>public.Book</code>.
|
||||
*/
|
||||
public static final Book BOOK = Book.BOOK;
|
||||
|
||||
/**
|
||||
* The table <code>public.BookAuthor</code>.
|
||||
*/
|
||||
public static final Bookauthor BOOKAUTHOR = Bookauthor.BOOKAUTHOR;
|
||||
|
||||
/**
|
||||
* The table <code>public.Store</code>.
|
||||
*/
|
||||
public static final Store STORE = Store.STORE;
|
||||
}
|
@ -0,0 +1,238 @@
|
||||
/*
|
||||
* This file is generated by jOOQ.
|
||||
*/
|
||||
package com.baeldung.jooq.jointables.public_.tables;
|
||||
|
||||
|
||||
import com.baeldung.jooq.jointables.public_.Keys;
|
||||
import com.baeldung.jooq.jointables.public_.Public;
|
||||
import com.baeldung.jooq.jointables.public_.tables.records.BookRecord;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.jooq.Condition;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.PlainSQL;
|
||||
import org.jooq.QueryPart;
|
||||
import org.jooq.SQL;
|
||||
import org.jooq.Schema;
|
||||
import org.jooq.Select;
|
||||
import org.jooq.Stringly;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableField;
|
||||
import org.jooq.TableOptions;
|
||||
import org.jooq.UniqueKey;
|
||||
import org.jooq.impl.DSL;
|
||||
import org.jooq.impl.SQLDataType;
|
||||
import org.jooq.impl.TableImpl;
|
||||
|
||||
|
||||
/**
|
||||
* This class is generated by jOOQ.
|
||||
*/
|
||||
@SuppressWarnings({ "all", "unchecked", "rawtypes", "this-escape" })
|
||||
public class Book extends TableImpl<BookRecord> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* The reference instance of <code>public.Book</code>
|
||||
*/
|
||||
public static final Book BOOK = new Book();
|
||||
|
||||
/**
|
||||
* The class holding records for this type
|
||||
*/
|
||||
@Override
|
||||
public Class<BookRecord> getRecordType() {
|
||||
return BookRecord.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* The column <code>public.Book.id</code>.
|
||||
*/
|
||||
public final TableField<BookRecord, Integer> ID = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>public.Book.author_id</code>.
|
||||
*/
|
||||
public final TableField<BookRecord, Integer> AUTHOR_ID = createField(DSL.name("author_id"), SQLDataType.INTEGER, this, "");
|
||||
|
||||
/**
|
||||
* The column <code>public.Book.title</code>.
|
||||
*/
|
||||
public final TableField<BookRecord, String> TITLE = createField(DSL.name("title"), SQLDataType.VARCHAR, this, "");
|
||||
|
||||
/**
|
||||
* The column <code>public.Book.description</code>.
|
||||
*/
|
||||
public final TableField<BookRecord, String> DESCRIPTION = createField(DSL.name("description"), SQLDataType.VARCHAR, this, "");
|
||||
|
||||
/**
|
||||
* The column <code>public.Book.store_id</code>.
|
||||
*/
|
||||
public final TableField<BookRecord, Integer> STORE_ID = createField(DSL.name("store_id"), SQLDataType.INTEGER, this, "");
|
||||
|
||||
private Book(Name alias, Table<BookRecord> aliased) {
|
||||
this(alias, aliased, (Field<?>[]) null, null);
|
||||
}
|
||||
|
||||
private Book(Name alias, Table<BookRecord> aliased, Field<?>[] parameters, Condition where) {
|
||||
super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table(), where);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an aliased <code>public.Book</code> table reference
|
||||
*/
|
||||
public Book(String alias) {
|
||||
this(DSL.name(alias), BOOK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an aliased <code>public.Book</code> table reference
|
||||
*/
|
||||
public Book(Name alias) {
|
||||
this(alias, BOOK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a <code>public.Book</code> table reference
|
||||
*/
|
||||
public Book() {
|
||||
this(DSL.name("Book"), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Schema getSchema() {
|
||||
return aliased() ? null : Public.PUBLIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UniqueKey<BookRecord> getPrimaryKey() {
|
||||
return Keys.BOOK_PKEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Book as(String alias) {
|
||||
return new Book(DSL.name(alias), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Book as(Name alias) {
|
||||
return new Book(alias, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Book as(Table<?> alias) {
|
||||
return new Book(alias.getQualifiedName(), 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename this table
|
||||
*/
|
||||
@Override
|
||||
public Book rename(Table<?> name) {
|
||||
return new Book(name.getQualifiedName(), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
public Book where(Condition condition) {
|
||||
return new Book(getQualifiedName(), aliased() ? this : null, null, condition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
public Book where(Collection<? extends Condition> conditions) {
|
||||
return where(DSL.and(conditions));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
public Book where(Condition... conditions) {
|
||||
return where(DSL.and(conditions));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
public Book where(Field<Boolean> condition) {
|
||||
return where(DSL.condition(condition));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
@PlainSQL
|
||||
public Book where(SQL condition) {
|
||||
return where(DSL.condition(condition));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
@PlainSQL
|
||||
public Book where(@Stringly.SQL String condition) {
|
||||
return where(DSL.condition(condition));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
@PlainSQL
|
||||
public Book where(@Stringly.SQL String condition, Object... binds) {
|
||||
return where(DSL.condition(condition, binds));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
@PlainSQL
|
||||
public Book where(@Stringly.SQL String condition, QueryPart... parts) {
|
||||
return where(DSL.condition(condition, parts));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
public Book whereExists(Select<?> select) {
|
||||
return where(DSL.exists(select));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
public Book whereNotExists(Select<?> select) {
|
||||
return where(DSL.notExists(select));
|
||||
}
|
||||
}
|
@ -0,0 +1,228 @@
|
||||
/*
|
||||
* This file is generated by jOOQ.
|
||||
*/
|
||||
package com.baeldung.jooq.jointables.public_.tables;
|
||||
|
||||
|
||||
import com.baeldung.jooq.jointables.public_.Keys;
|
||||
import com.baeldung.jooq.jointables.public_.Public;
|
||||
import com.baeldung.jooq.jointables.public_.tables.records.BookauthorRecord;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.jooq.Condition;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.PlainSQL;
|
||||
import org.jooq.QueryPart;
|
||||
import org.jooq.SQL;
|
||||
import org.jooq.Schema;
|
||||
import org.jooq.Select;
|
||||
import org.jooq.Stringly;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableField;
|
||||
import org.jooq.TableOptions;
|
||||
import org.jooq.UniqueKey;
|
||||
import org.jooq.impl.DSL;
|
||||
import org.jooq.impl.SQLDataType;
|
||||
import org.jooq.impl.TableImpl;
|
||||
|
||||
|
||||
/**
|
||||
* This class is generated by jOOQ.
|
||||
*/
|
||||
@SuppressWarnings({ "all", "unchecked", "rawtypes", "this-escape" })
|
||||
public class Bookauthor extends TableImpl<BookauthorRecord> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* The reference instance of <code>public.BookAuthor</code>
|
||||
*/
|
||||
public static final Bookauthor BOOKAUTHOR = new Bookauthor();
|
||||
|
||||
/**
|
||||
* The class holding records for this type
|
||||
*/
|
||||
@Override
|
||||
public Class<BookauthorRecord> getRecordType() {
|
||||
return BookauthorRecord.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* The column <code>public.BookAuthor.id</code>.
|
||||
*/
|
||||
public final TableField<BookauthorRecord, Integer> ID = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>public.BookAuthor.name</code>.
|
||||
*/
|
||||
public final TableField<BookauthorRecord, String> NAME = createField(DSL.name("name"), SQLDataType.VARCHAR.nullable(false), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>public.BookAuthor.country</code>.
|
||||
*/
|
||||
public final TableField<BookauthorRecord, String> COUNTRY = createField(DSL.name("country"), SQLDataType.VARCHAR, this, "");
|
||||
|
||||
private Bookauthor(Name alias, Table<BookauthorRecord> aliased) {
|
||||
this(alias, aliased, (Field<?>[]) null, null);
|
||||
}
|
||||
|
||||
private Bookauthor(Name alias, Table<BookauthorRecord> aliased, Field<?>[] parameters, Condition where) {
|
||||
super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table(), where);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an aliased <code>public.BookAuthor</code> table reference
|
||||
*/
|
||||
public Bookauthor(String alias) {
|
||||
this(DSL.name(alias), BOOKAUTHOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an aliased <code>public.BookAuthor</code> table reference
|
||||
*/
|
||||
public Bookauthor(Name alias) {
|
||||
this(alias, BOOKAUTHOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a <code>public.BookAuthor</code> table reference
|
||||
*/
|
||||
public Bookauthor() {
|
||||
this(DSL.name("BookAuthor"), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Schema getSchema() {
|
||||
return aliased() ? null : Public.PUBLIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UniqueKey<BookauthorRecord> getPrimaryKey() {
|
||||
return Keys.AUTHOR_PKEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bookauthor as(String alias) {
|
||||
return new Bookauthor(DSL.name(alias), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bookauthor as(Name alias) {
|
||||
return new Bookauthor(alias, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bookauthor as(Table<?> alias) {
|
||||
return new Bookauthor(alias.getQualifiedName(), this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename this table
|
||||
*/
|
||||
@Override
|
||||
public Bookauthor rename(String name) {
|
||||
return new Bookauthor(DSL.name(name), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename this table
|
||||
*/
|
||||
@Override
|
||||
public Bookauthor rename(Name name) {
|
||||
return new Bookauthor(name, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename this table
|
||||
*/
|
||||
@Override
|
||||
public Bookauthor rename(Table<?> name) {
|
||||
return new Bookauthor(name.getQualifiedName(), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
public Bookauthor where(Condition condition) {
|
||||
return new Bookauthor(getQualifiedName(), aliased() ? this : null, null, condition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
public Bookauthor where(Collection<? extends Condition> conditions) {
|
||||
return where(DSL.and(conditions));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
public Bookauthor where(Condition... conditions) {
|
||||
return where(DSL.and(conditions));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
public Bookauthor where(Field<Boolean> condition) {
|
||||
return where(DSL.condition(condition));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
@PlainSQL
|
||||
public Bookauthor where(SQL condition) {
|
||||
return where(DSL.condition(condition));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
@PlainSQL
|
||||
public Bookauthor where(@Stringly.SQL String condition) {
|
||||
return where(DSL.condition(condition));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
@PlainSQL
|
||||
public Bookauthor where(@Stringly.SQL String condition, Object... binds) {
|
||||
return where(DSL.condition(condition, binds));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
@PlainSQL
|
||||
public Bookauthor where(@Stringly.SQL String condition, QueryPart... parts) {
|
||||
return where(DSL.condition(condition, parts));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
public Bookauthor whereExists(Select<?> select) {
|
||||
return where(DSL.exists(select));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
public Bookauthor whereNotExists(Select<?> select) {
|
||||
return where(DSL.notExists(select));
|
||||
}
|
||||
}
|
@ -0,0 +1,223 @@
|
||||
/*
|
||||
* This file is generated by jOOQ.
|
||||
*/
|
||||
package com.baeldung.jooq.jointables.public_.tables;
|
||||
|
||||
|
||||
import com.baeldung.jooq.jointables.public_.Keys;
|
||||
import com.baeldung.jooq.jointables.public_.Public;
|
||||
import com.baeldung.jooq.jointables.public_.tables.records.StoreRecord;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.jooq.Condition;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.PlainSQL;
|
||||
import org.jooq.QueryPart;
|
||||
import org.jooq.SQL;
|
||||
import org.jooq.Schema;
|
||||
import org.jooq.Select;
|
||||
import org.jooq.Stringly;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableField;
|
||||
import org.jooq.TableOptions;
|
||||
import org.jooq.UniqueKey;
|
||||
import org.jooq.impl.DSL;
|
||||
import org.jooq.impl.SQLDataType;
|
||||
import org.jooq.impl.TableImpl;
|
||||
|
||||
|
||||
/**
|
||||
* This class is generated by jOOQ.
|
||||
*/
|
||||
@SuppressWarnings({ "all", "unchecked", "rawtypes", "this-escape" })
|
||||
public class Store extends TableImpl<StoreRecord> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* The reference instance of <code>public.Store</code>
|
||||
*/
|
||||
public static final Store STORE = new Store();
|
||||
|
||||
/**
|
||||
* The class holding records for this type
|
||||
*/
|
||||
@Override
|
||||
public Class<StoreRecord> getRecordType() {
|
||||
return StoreRecord.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* The column <code>public.Store.id</code>.
|
||||
*/
|
||||
public final TableField<StoreRecord, Integer> ID = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>public.Store.name</code>.
|
||||
*/
|
||||
public final TableField<StoreRecord, String> NAME = createField(DSL.name("name"), SQLDataType.VARCHAR.nullable(false), this, "");
|
||||
|
||||
private Store(Name alias, Table<StoreRecord> aliased) {
|
||||
this(alias, aliased, (Field<?>[]) null, null);
|
||||
}
|
||||
|
||||
private Store(Name alias, Table<StoreRecord> aliased, Field<?>[] parameters, Condition where) {
|
||||
super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table(), where);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an aliased <code>public.Store</code> table reference
|
||||
*/
|
||||
public Store(String alias) {
|
||||
this(DSL.name(alias), STORE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an aliased <code>public.Store</code> table reference
|
||||
*/
|
||||
public Store(Name alias) {
|
||||
this(alias, STORE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a <code>public.Store</code> table reference
|
||||
*/
|
||||
public Store() {
|
||||
this(DSL.name("Store"), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Schema getSchema() {
|
||||
return aliased() ? null : Public.PUBLIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UniqueKey<StoreRecord> getPrimaryKey() {
|
||||
return Keys.STORE_PKEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Store as(String alias) {
|
||||
return new Store(DSL.name(alias), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Store as(Name alias) {
|
||||
return new Store(alias, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Store as(Table<?> alias) {
|
||||
return new Store(alias.getQualifiedName(), this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename this table
|
||||
*/
|
||||
@Override
|
||||
public Store rename(String name) {
|
||||
return new Store(DSL.name(name), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename this table
|
||||
*/
|
||||
@Override
|
||||
public Store rename(Name name) {
|
||||
return new Store(name, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename this table
|
||||
*/
|
||||
@Override
|
||||
public Store rename(Table<?> name) {
|
||||
return new Store(name.getQualifiedName(), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
public Store where(Condition condition) {
|
||||
return new Store(getQualifiedName(), aliased() ? this : null, null, condition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
public Store where(Collection<? extends Condition> conditions) {
|
||||
return where(DSL.and(conditions));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
public Store where(Condition... conditions) {
|
||||
return where(DSL.and(conditions));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
public Store where(Field<Boolean> condition) {
|
||||
return where(DSL.condition(condition));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
@PlainSQL
|
||||
public Store where(SQL condition) {
|
||||
return where(DSL.condition(condition));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
@PlainSQL
|
||||
public Store where(@Stringly.SQL String condition) {
|
||||
return where(DSL.condition(condition));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
@PlainSQL
|
||||
public Store where(@Stringly.SQL String condition, Object... binds) {
|
||||
return where(DSL.condition(condition, binds));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
@PlainSQL
|
||||
public Store where(@Stringly.SQL String condition, QueryPart... parts) {
|
||||
return where(DSL.condition(condition, parts));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
public Store whereExists(Select<?> select) {
|
||||
return where(DSL.exists(select));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an inline derived table from this table
|
||||
*/
|
||||
@Override
|
||||
public Store whereNotExists(Select<?> select) {
|
||||
return where(DSL.notExists(select));
|
||||
}
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
/*
|
||||
* This file is generated by jOOQ.
|
||||
*/
|
||||
package com.baeldung.jooq.jointables.public_.tables.records;
|
||||
|
||||
|
||||
import com.baeldung.jooq.jointables.public_.tables.Book;
|
||||
|
||||
import org.jooq.Record1;
|
||||
import org.jooq.impl.UpdatableRecordImpl;
|
||||
|
||||
|
||||
/**
|
||||
* This class is generated by jOOQ.
|
||||
*/
|
||||
@SuppressWarnings({ "all", "unchecked", "rawtypes", "this-escape" })
|
||||
public class BookRecord extends UpdatableRecordImpl<BookRecord> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Setter for <code>public.Book.id</code>.
|
||||
*/
|
||||
public void setId(Integer value) {
|
||||
set(0, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>public.Book.id</code>.
|
||||
*/
|
||||
public Integer getId() {
|
||||
return (Integer) get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>public.Book.author_id</code>.
|
||||
*/
|
||||
public void setAuthorId(Integer value) {
|
||||
set(1, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>public.Book.author_id</code>.
|
||||
*/
|
||||
public Integer getAuthorId() {
|
||||
return (Integer) get(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>public.Book.title</code>.
|
||||
*/
|
||||
public void setTitle(String value) {
|
||||
set(2, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>public.Book.title</code>.
|
||||
*/
|
||||
public String getTitle() {
|
||||
return (String) get(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>public.Book.description</code>.
|
||||
*/
|
||||
public void setDescription(String value) {
|
||||
set(3, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>public.Book.description</code>.
|
||||
*/
|
||||
public String getDescription() {
|
||||
return (String) get(3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>public.Book.store_id</code>.
|
||||
*/
|
||||
public void setStoreId(Integer value) {
|
||||
set(4, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>public.Book.store_id</code>.
|
||||
*/
|
||||
public Integer getStoreId() {
|
||||
return (Integer) get(4);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Primary key information
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public Record1<Integer> key() {
|
||||
return (Record1) super.key();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Constructors
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create a detached BookRecord
|
||||
*/
|
||||
public BookRecord() {
|
||||
super(Book.BOOK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a detached, initialised BookRecord
|
||||
*/
|
||||
public BookRecord(Integer id, Integer authorId, String title, String description, Integer storeId) {
|
||||
super(Book.BOOK);
|
||||
|
||||
setId(id);
|
||||
setAuthorId(authorId);
|
||||
setTitle(title);
|
||||
setDescription(description);
|
||||
setStoreId(storeId);
|
||||
resetChangedOnNotNull();
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* This file is generated by jOOQ.
|
||||
*/
|
||||
package com.baeldung.jooq.jointables.public_.tables.records;
|
||||
|
||||
|
||||
import com.baeldung.jooq.jointables.public_.tables.Bookauthor;
|
||||
|
||||
import org.jooq.Record1;
|
||||
import org.jooq.impl.UpdatableRecordImpl;
|
||||
|
||||
|
||||
/**
|
||||
* This class is generated by jOOQ.
|
||||
*/
|
||||
@SuppressWarnings({ "all", "unchecked", "rawtypes", "this-escape" })
|
||||
public class BookauthorRecord extends UpdatableRecordImpl<BookauthorRecord> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Setter for <code>public.BookAuthor.id</code>.
|
||||
*/
|
||||
public void setId(Integer value) {
|
||||
set(0, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>public.BookAuthor.id</code>.
|
||||
*/
|
||||
public Integer getId() {
|
||||
return (Integer) get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>public.BookAuthor.name</code>.
|
||||
*/
|
||||
public void setName(String value) {
|
||||
set(1, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>public.BookAuthor.name</code>.
|
||||
*/
|
||||
public String getName() {
|
||||
return (String) get(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>public.BookAuthor.country</code>.
|
||||
*/
|
||||
public void setCountry(String value) {
|
||||
set(2, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>public.BookAuthor.country</code>.
|
||||
*/
|
||||
public String getCountry() {
|
||||
return (String) get(2);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Primary key information
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public Record1<Integer> key() {
|
||||
return (Record1) super.key();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Constructors
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create a detached BookauthorRecord
|
||||
*/
|
||||
public BookauthorRecord() {
|
||||
super(Bookauthor.BOOKAUTHOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a detached, initialised BookauthorRecord
|
||||
*/
|
||||
public BookauthorRecord(Integer id, String name, String country) {
|
||||
super(Bookauthor.BOOKAUTHOR);
|
||||
|
||||
setId(id);
|
||||
setName(name);
|
||||
setCountry(country);
|
||||
resetChangedOnNotNull();
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* This file is generated by jOOQ.
|
||||
*/
|
||||
package com.baeldung.jooq.jointables.public_.tables.records;
|
||||
|
||||
|
||||
import com.baeldung.jooq.jointables.public_.tables.Store;
|
||||
|
||||
import org.jooq.Record1;
|
||||
import org.jooq.impl.UpdatableRecordImpl;
|
||||
|
||||
|
||||
/**
|
||||
* This class is generated by jOOQ.
|
||||
*/
|
||||
@SuppressWarnings({ "all", "unchecked", "rawtypes", "this-escape" })
|
||||
public class StoreRecord extends UpdatableRecordImpl<StoreRecord> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Setter for <code>public.Store.id</code>.
|
||||
*/
|
||||
public void setId(Integer value) {
|
||||
set(0, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>public.Store.id</code>.
|
||||
*/
|
||||
public Integer getId() {
|
||||
return (Integer) get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>public.Store.name</code>.
|
||||
*/
|
||||
public void setName(String value) {
|
||||
set(1, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>public.Store.name</code>.
|
||||
*/
|
||||
public String getName() {
|
||||
return (String) get(1);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Primary key information
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public Record1<Integer> key() {
|
||||
return (Record1) super.key();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Constructors
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create a detached StoreRecord
|
||||
*/
|
||||
public StoreRecord() {
|
||||
super(Store.STORE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a detached, initialised StoreRecord
|
||||
*/
|
||||
public StoreRecord(Integer id, String name) {
|
||||
super(Store.STORE);
|
||||
|
||||
setId(id);
|
||||
setName(name);
|
||||
resetChangedOnNotNull();
|
||||
}
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
package com.baeldung.jooq.jointables;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.Result;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.impl.DSL;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.jooq.jointables.public_.Tables;
|
||||
import com.baeldung.jooq.jointables.public_.tables.Book;
|
||||
import com.baeldung.jooq.jointables.public_.tables.Bookauthor;
|
||||
import com.baeldung.jooq.jointables.public_.tables.Store;
|
||||
|
||||
public class JoinTablesIntegrationTest {
|
||||
|
||||
static DSLContext context;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
// URL jooqConfigURL = getClass().getClassLoader().getResource("jooq-config-2.xml");
|
||||
// File file = new File(jooqConfigURL.getFile());
|
||||
// GenerationTool.generate(Files.readString(file.toPath()));
|
||||
|
||||
String url = "jdbc:postgresql://localhost:5432/postgres";
|
||||
String username = "postgres";
|
||||
String password = "";
|
||||
|
||||
Connection conn = DriverManager.getConnection(url, username, password);
|
||||
context = DSL.using(conn, SQLDialect.POSTGRES);
|
||||
|
||||
context.insertInto(Tables.STORE, Store.STORE.ID, Store.STORE.NAME)
|
||||
.values(1, "ABC Branch I ")
|
||||
.values(2, "ABC Branch II")
|
||||
.execute();
|
||||
|
||||
context.insertInto(Tables.BOOK, Book.BOOK.ID, Book.BOOK.TITLE, Book.BOOK.DESCRIPTION, Book.BOOK.AUTHOR_ID, Book.BOOK.STORE_ID)
|
||||
.values(1, "Book 1", "This is book 1", 1, 1)
|
||||
.values(2, "Book 2", "This is book 2", 2, 2)
|
||||
.values(3, "Book 3", "This is book 3", 1, 2)
|
||||
.values(4, "Book 4", "This is book 4", 5, 1)
|
||||
.execute();
|
||||
|
||||
context.insertInto(Tables.BOOKAUTHOR, Bookauthor.BOOKAUTHOR.ID, Bookauthor.BOOKAUTHOR.NAME, Bookauthor.BOOKAUTHOR.COUNTRY)
|
||||
.values(1, "John Smith", "Japan")
|
||||
.values(2, "William Walce", "Japan")
|
||||
.values(3, "Marry Sity", "South Korea")
|
||||
.values(4, "Morry Toh", "England")
|
||||
.execute();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void cleanup() throws Exception {
|
||||
context.truncateTable(Store.STORE)
|
||||
.execute();
|
||||
context.truncateTable(Book.BOOK)
|
||||
.execute();
|
||||
context.truncateTable(Bookauthor.BOOKAUTHOR)
|
||||
.execute();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void _whenUsingJoinMethod_thenQueryExecuted() {
|
||||
Result<Record> result = JoinTables.usingJoinMethod(context);
|
||||
assertEquals(3, result.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void _whenUsingMultipleJoinMethod_thenQueryExecuted() {
|
||||
Result<Record> result = JoinTables.usingMultipleJoinMethod(context);
|
||||
assertEquals(3, result.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenContext_whenUsingLeftOuterJoinMethod_thenQueryExecuted() {
|
||||
Result<Record> result = JoinTables.usingLeftOuterJoinMethod(context);
|
||||
assertEquals(4, result.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingRightOuterJoinMethod_thenQueryExecuted() {
|
||||
Result<Record> result = JoinTables.usingRightOuterJoinMethod(context);
|
||||
assertEquals(5, result.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingFullOuterJoinMethod_thenQueryExecuted() {
|
||||
Result<Record> result = JoinTables.usingFullOuterJoinMethod(context);
|
||||
assertEquals(6, result.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingNaturalJoinMethod_thenQueryExecuted() {
|
||||
Result<Record> result = JoinTables.usingNaturalJoinMethod(context);
|
||||
assertEquals(4, result.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingCrossJoinMethod_thenQueryExecuted() {
|
||||
Result<Record> result = JoinTables.usingCrossJoinMethod(context);
|
||||
assertEquals(8, result.size());
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.15.0.xsd">
|
||||
<jdbc>
|
||||
<driver>org.postgresql.Driver</driver>
|
||||
<url>jdbc:postgresql://localhost:5432/postgres</url>
|
||||
<user>postgres</user>
|
||||
<password></password>
|
||||
</jdbc>
|
||||
<generator>
|
||||
<database>
|
||||
<name>org.jooq.meta.postgres.PostgresDatabase</name>
|
||||
<includes>Store|Book|BookAuthor</includes>
|
||||
<excludes></excludes>
|
||||
</database>
|
||||
<target>
|
||||
<packageName>com.baeldung.jooq.jointables</packageName>
|
||||
<directory>src/main/java</directory>
|
||||
</target>
|
||||
</generator>
|
||||
</configuration>
|
Loading…
x
Reference in New Issue
Block a user