diff --git a/jOOQ-codegen/src/main/java/org/jooq/codegen/AbstractGenerator.java b/jOOQ-codegen/src/main/java/org/jooq/codegen/AbstractGenerator.java index c1573ae788..d3a56b4d9d 100644 --- a/jOOQ-codegen/src/main/java/org/jooq/codegen/AbstractGenerator.java +++ b/jOOQ-codegen/src/main/java/org/jooq/codegen/AbstractGenerator.java @@ -69,6 +69,9 @@ abstract class AbstractGenerator implements Generator { boolean generateIndexes = true; boolean generateRelations = true; boolean generateImplicitJoinPathsToOne = true; + boolean generateRowConvenienceToOne = true; + boolean generateMultisetConvenienceOneToMany = true; + boolean generateMultisetConvenienceManyToMany = true; boolean generateInstanceFields = true; VisibilityModifier generateVisibilityModifier = VisibilityModifier.DEFAULT; boolean generateGeneratedAnnotation = false; @@ -287,6 +290,36 @@ abstract class AbstractGenerator implements Generator { this.generateImplicitJoinPathsToOne = generateImplicitJoinPathsToOne; } + @Override + public boolean generateRowConvenienceToOne() { + return generateRowConvenienceToOne && generateRelations(); + } + + @Override + public void setGenerateRowConvenienceToOne(boolean generateRowConvenienceToOne) { + this.generateRowConvenienceToOne = generateRowConvenienceToOne; + } + + @Override + public boolean generateMultisetConvenienceOneToMany() { + return generateMultisetConvenienceOneToMany && generateRelations(); + } + + @Override + public void setGenerateMultisetConvenienceOneToMany(boolean generateMultisetConvenienceOneToMany) { + this.generateMultisetConvenienceOneToMany = generateMultisetConvenienceOneToMany; + } + + @Override + public boolean generateMultisetConvenienceManyToMany() { + return generateMultisetConvenienceManyToMany && generateRelations(); + } + + @Override + public void setGenerateMultisetConvenienceManyToMany(boolean generateMultisetConvenienceManyToMany) { + this.generateMultisetConvenienceManyToMany = generateMultisetConvenienceManyToMany; + } + @Override public boolean generateTableValuedFunctions() { return generateTableValuedFunctions; diff --git a/jOOQ-codegen/src/main/java/org/jooq/codegen/GenerationTool.java b/jOOQ-codegen/src/main/java/org/jooq/codegen/GenerationTool.java index 1d17abfeca..c09b4d8ebd 100644 --- a/jOOQ-codegen/src/main/java/org/jooq/codegen/GenerationTool.java +++ b/jOOQ-codegen/src/main/java/org/jooq/codegen/GenerationTool.java @@ -705,6 +705,12 @@ public class GenerationTool { generator.setGenerateRelations(g.getGenerate().isRelations()); if (g.getGenerate().isImplicitJoinPathsToOne() != null) generator.setGenerateImplicitJoinPathsToOne(g.getGenerate().isImplicitJoinPathsToOne()); + if (g.getGenerate().isRowConvenienceToOne() != null) + generator.setGenerateRowConvenienceToOne(g.getGenerate().isRowConvenienceToOne()); + if (g.getGenerate().isMultisetConvenienceOneToMany() != null) + generator.setGenerateMultisetConvenienceOneToMany(g.getGenerate().isMultisetConvenienceOneToMany()); + if (g.getGenerate().isMultisetConvenienceManyToMany() != null) + generator.setGenerateMultisetConvenienceManyToMany(g.getGenerate().isMultisetConvenienceManyToMany()); if (g.getGenerate().isDeprecated() != null) generator.setGenerateDeprecated(g.getGenerate().isDeprecated()); if (g.getGenerate().isDeprecationOnUnknownTypes() != null) diff --git a/jOOQ-codegen/src/main/java/org/jooq/codegen/Generator.java b/jOOQ-codegen/src/main/java/org/jooq/codegen/Generator.java index f02913bc95..aa31fd0d1c 100644 --- a/jOOQ-codegen/src/main/java/org/jooq/codegen/Generator.java +++ b/jOOQ-codegen/src/main/java/org/jooq/codegen/Generator.java @@ -121,6 +121,42 @@ public interface Generator { */ void setGenerateImplicitJoinPathsToOne(boolean generateImplicitJoinPathsToOne); + /** + * Whether ROW convenience syntax for to-one relationships + * should be generated. + */ + boolean generateRowConvenienceToOne(); + + /** + * Whether ROW convenience syntax for to-one relationships + * should be generated. + */ + void setGenerateRowConvenienceToOne(boolean generateRowConvenienceToOne); + + /** + * Whether MULTISET convenience syntax for one-to-many + * relationships should be generated. + */ + boolean generateMultisetConvenienceOneToMany(); + + /** + * Whether MULTISET convenience syntax for one-to-many + * relationships should be generated. + */ + void setGenerateMultisetConvenienceOneToMany(boolean generateMultisetConvenienceOneToMany); + + /** + * Whether MULTISET convenience syntax for many-to-many + * relationships should be generated. + */ + boolean generateMultisetConvenienceManyToMany(); + + /** + * Whether MULTISET convenience syntax for many-to-many + * relationships should be generated. + */ + void setGenerateMultisetConvenienceManyToMany(boolean generateMultisetConvenienceManyToMany); + /** * Whether table-valued functions should be generated as tables. */ diff --git a/jOOQ-codegen/src/main/java/org/jooq/codegen/JavaGenerator.java b/jOOQ-codegen/src/main/java/org/jooq/codegen/JavaGenerator.java index a81fd39327..73f4f01ba1 100644 --- a/jOOQ-codegen/src/main/java/org/jooq/codegen/JavaGenerator.java +++ b/jOOQ-codegen/src/main/java/org/jooq/codegen/JavaGenerator.java @@ -83,13 +83,12 @@ import java.util.Optional; import java.util.Set; import java.util.TimeZone; import java.util.function.BiConsumer; +import java.util.function.Function; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; -import jakarta.xml.bind.DatatypeConverter; - import org.jooq.AggregateFunction; import org.jooq.Catalog; import org.jooq.Check; @@ -117,6 +116,7 @@ import org.jooq.Sequence; import org.jooq.SortOrder; import org.jooq.Table; import org.jooq.TableField; +import org.jooq.TableLike; import org.jooq.TableOptions; import org.jooq.UDT; import org.jooq.UDTField; @@ -187,6 +187,8 @@ import org.jooq.tools.reflect.Reflect; import org.jooq.tools.reflect.ReflectException; // ... +import jakarta.xml.bind.DatatypeConverter; + /** * A default implementation for code generation. @@ -5995,6 +5997,167 @@ public class JavaGenerator extends AbstractGenerator { } } } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + } List cc = table.getCheckConstraints(); diff --git a/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Actor.java b/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Actor.java index 8e4abc474f..3f5fada8cf 100644 --- a/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Actor.java +++ b/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Actor.java @@ -7,6 +7,7 @@ package org.jooq.example.testcontainers.db.tables; import java.time.LocalDateTime; import java.util.Arrays; import java.util.List; +import java.util.function.Function; import org.jooq.Field; import org.jooq.ForeignKey; @@ -14,16 +15,20 @@ import org.jooq.Identity; import org.jooq.Index; import org.jooq.Name; import org.jooq.Record; +import org.jooq.Result; import org.jooq.Row4; import org.jooq.Schema; import org.jooq.Table; import org.jooq.TableField; +import org.jooq.TableLike; import org.jooq.TableOptions; import org.jooq.UniqueKey; import org.jooq.example.testcontainers.db.Indexes; import org.jooq.example.testcontainers.db.Keys; import org.jooq.example.testcontainers.db.Public; import org.jooq.example.testcontainers.db.tables.records.ActorRecord; +import org.jooq.example.testcontainers.db.tables.records.FilmActorRecord; +import org.jooq.example.testcontainers.db.tables.records.FilmRecord; import org.jooq.impl.DSL; import org.jooq.impl.SQLDataType; import org.jooq.impl.TableImpl; @@ -123,6 +128,40 @@ public class Actor extends TableImpl { return Keys.ACTOR_PKEY; } + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.film_actor one-to-many child + * table. + */ + public Field> filmActorMultiset() { + return filmActorMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.film_actor one-to-many child + * table. + */ + public Field> filmActorMultiset(Function> subquery) { + return oneToManyMultiset(Keys.FILM_ACTOR__FILM_ACTOR_ACTOR_ID_FKEY, t -> subquery.apply((FilmActor) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.film many-to-many child table. + */ + public Field> filmMultiset() { + return filmMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.film many-to-many child table. + */ + public Field> filmMultiset(Function> subquery) { + return manyToManyMultiset(Keys.FILM_ACTOR__FILM_ACTOR_ACTOR_ID_FKEY, Keys.FILM_ACTOR__FILM_ACTOR_FILM_ID_FKEY, t -> subquery.apply((Film) t)); + } + @Override public Actor as(String alias) { return new Actor(DSL.name(alias), this); diff --git a/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Address.java b/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Address.java index bdd64ac186..90e95bbbd1 100644 --- a/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Address.java +++ b/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Address.java @@ -7,6 +7,7 @@ package org.jooq.example.testcontainers.db.tables; import java.time.LocalDateTime; import java.util.Arrays; import java.util.List; +import java.util.function.Function; import org.jooq.Field; import org.jooq.ForeignKey; @@ -14,16 +15,21 @@ import org.jooq.Identity; import org.jooq.Index; import org.jooq.Name; import org.jooq.Record; +import org.jooq.Result; import org.jooq.Row8; import org.jooq.Schema; import org.jooq.Table; import org.jooq.TableField; +import org.jooq.TableLike; import org.jooq.TableOptions; import org.jooq.UniqueKey; import org.jooq.example.testcontainers.db.Indexes; import org.jooq.example.testcontainers.db.Keys; import org.jooq.example.testcontainers.db.Public; import org.jooq.example.testcontainers.db.tables.records.AddressRecord; +import org.jooq.example.testcontainers.db.tables.records.CustomerRecord; +import org.jooq.example.testcontainers.db.tables.records.StaffRecord; +import org.jooq.example.testcontainers.db.tables.records.StoreRecord; import org.jooq.impl.DSL; import org.jooq.impl.SQLDataType; import org.jooq.impl.TableImpl; @@ -160,6 +166,54 @@ public class Address extends TableImpl { return _city; } + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.customer one-to-many child table. + */ + public Field> customerMultiset() { + return customerMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.customer one-to-many child table. + */ + public Field> customerMultiset(Function> subquery) { + return oneToManyMultiset(Keys.CUSTOMER__CUSTOMER_ADDRESS_ID_FKEY, t -> subquery.apply((Customer) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.staff one-to-many child table. + */ + public Field> staffMultiset() { + return staffMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.staff one-to-many child table. + */ + public Field> staffMultiset(Function> subquery) { + return oneToManyMultiset(Keys.STAFF__STAFF_ADDRESS_ID_FKEY, t -> subquery.apply((Staff) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.store one-to-many child table. + */ + public Field> storeMultiset() { + return storeMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.store one-to-many child table. + */ + public Field> storeMultiset(Function> subquery) { + return oneToManyMultiset(Keys.STORE__STORE_ADDRESS_ID_FKEY, t -> subquery.apply((Store) t)); + } + @Override public Address as(String alias) { return new Address(DSL.name(alias), this); diff --git a/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Category.java b/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Category.java index 0746d0214f..af824b8877 100644 --- a/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Category.java +++ b/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Category.java @@ -5,21 +5,26 @@ package org.jooq.example.testcontainers.db.tables; import java.time.LocalDateTime; +import java.util.function.Function; import org.jooq.Field; import org.jooq.ForeignKey; import org.jooq.Identity; import org.jooq.Name; import org.jooq.Record; +import org.jooq.Result; import org.jooq.Row3; import org.jooq.Schema; import org.jooq.Table; import org.jooq.TableField; +import org.jooq.TableLike; import org.jooq.TableOptions; import org.jooq.UniqueKey; import org.jooq.example.testcontainers.db.Keys; import org.jooq.example.testcontainers.db.Public; import org.jooq.example.testcontainers.db.tables.records.CategoryRecord; +import org.jooq.example.testcontainers.db.tables.records.FilmCategoryRecord; +import org.jooq.example.testcontainers.db.tables.records.FilmRecord; import org.jooq.impl.DSL; import org.jooq.impl.SQLDataType; import org.jooq.impl.TableImpl; @@ -109,6 +114,40 @@ public class Category extends TableImpl { return Keys.CATEGORY_PKEY; } + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.film_category one-to-many child + * table. + */ + public Field> filmCategoryMultiset() { + return filmCategoryMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.film_category one-to-many child + * table. + */ + public Field> filmCategoryMultiset(Function> subquery) { + return oneToManyMultiset(Keys.FILM_CATEGORY__FILM_CATEGORY_CATEGORY_ID_FKEY, t -> subquery.apply((FilmCategory) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.film many-to-many child table. + */ + public Field> filmMultiset() { + return filmMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.film many-to-many child table. + */ + public Field> filmMultiset(Function> subquery) { + return manyToManyMultiset(Keys.FILM_CATEGORY__FILM_CATEGORY_CATEGORY_ID_FKEY, Keys.FILM_CATEGORY__FILM_CATEGORY_FILM_ID_FKEY, t -> subquery.apply((Film) t)); + } + @Override public Category as(String alias) { return new Category(DSL.name(alias), this); diff --git a/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/City.java b/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/City.java index 94d6f3276c..11087570c4 100644 --- a/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/City.java +++ b/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/City.java @@ -7,6 +7,7 @@ package org.jooq.example.testcontainers.db.tables; import java.time.LocalDateTime; import java.util.Arrays; import java.util.List; +import java.util.function.Function; import org.jooq.Field; import org.jooq.ForeignKey; @@ -14,15 +15,18 @@ import org.jooq.Identity; import org.jooq.Index; import org.jooq.Name; import org.jooq.Record; +import org.jooq.Result; import org.jooq.Row4; import org.jooq.Schema; import org.jooq.Table; import org.jooq.TableField; +import org.jooq.TableLike; import org.jooq.TableOptions; import org.jooq.UniqueKey; import org.jooq.example.testcontainers.db.Indexes; import org.jooq.example.testcontainers.db.Keys; import org.jooq.example.testcontainers.db.Public; +import org.jooq.example.testcontainers.db.tables.records.AddressRecord; import org.jooq.example.testcontainers.db.tables.records.CityRecord; import org.jooq.impl.DSL; import org.jooq.impl.SQLDataType; @@ -140,6 +144,22 @@ public class City extends TableImpl { return _country; } + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.address one-to-many child table. + */ + public Field> addressMultiset() { + return addressMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.address one-to-many child table. + */ + public Field> addressMultiset(Function> subquery) { + return oneToManyMultiset(Keys.ADDRESS__ADDRESS_CITY_ID_FKEY, t -> subquery.apply((Address) t)); + } + @Override public City as(String alias) { return new City(DSL.name(alias), this); diff --git a/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Country.java b/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Country.java index e52183b194..89ca23f179 100644 --- a/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Country.java +++ b/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Country.java @@ -5,20 +5,24 @@ package org.jooq.example.testcontainers.db.tables; import java.time.LocalDateTime; +import java.util.function.Function; import org.jooq.Field; import org.jooq.ForeignKey; import org.jooq.Identity; import org.jooq.Name; import org.jooq.Record; +import org.jooq.Result; import org.jooq.Row3; import org.jooq.Schema; import org.jooq.Table; import org.jooq.TableField; +import org.jooq.TableLike; import org.jooq.TableOptions; import org.jooq.UniqueKey; import org.jooq.example.testcontainers.db.Keys; import org.jooq.example.testcontainers.db.Public; +import org.jooq.example.testcontainers.db.tables.records.CityRecord; import org.jooq.example.testcontainers.db.tables.records.CountryRecord; import org.jooq.impl.DSL; import org.jooq.impl.SQLDataType; @@ -109,6 +113,22 @@ public class Country extends TableImpl { return Keys.COUNTRY_PKEY; } + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.city one-to-many child table. + */ + public Field> cityMultiset() { + return cityMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.city one-to-many child table. + */ + public Field> cityMultiset(Function> subquery) { + return oneToManyMultiset(Keys.CITY__CITY_COUNTRY_ID_FKEY, t -> subquery.apply((City) t)); + } + @Override public Country as(String alias) { return new Country(DSL.name(alias), this); diff --git a/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Customer.java b/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Customer.java index 78c3834b19..bcd7537e91 100644 --- a/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Customer.java +++ b/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Customer.java @@ -8,6 +8,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.util.Arrays; import java.util.List; +import java.util.function.Function; import org.jooq.Field; import org.jooq.ForeignKey; @@ -15,16 +16,26 @@ import org.jooq.Identity; import org.jooq.Index; import org.jooq.Name; import org.jooq.Record; +import org.jooq.Result; import org.jooq.Row10; import org.jooq.Schema; import org.jooq.Table; import org.jooq.TableField; +import org.jooq.TableLike; import org.jooq.TableOptions; import org.jooq.UniqueKey; import org.jooq.example.testcontainers.db.Indexes; import org.jooq.example.testcontainers.db.Keys; import org.jooq.example.testcontainers.db.Public; import org.jooq.example.testcontainers.db.tables.records.CustomerRecord; +import org.jooq.example.testcontainers.db.tables.records.PaymentP2007_01Record; +import org.jooq.example.testcontainers.db.tables.records.PaymentP2007_02Record; +import org.jooq.example.testcontainers.db.tables.records.PaymentP2007_03Record; +import org.jooq.example.testcontainers.db.tables.records.PaymentP2007_04Record; +import org.jooq.example.testcontainers.db.tables.records.PaymentP2007_05Record; +import org.jooq.example.testcontainers.db.tables.records.PaymentP2007_06Record; +import org.jooq.example.testcontainers.db.tables.records.PaymentRecord; +import org.jooq.example.testcontainers.db.tables.records.RentalRecord; import org.jooq.impl.DSL; import org.jooq.impl.SQLDataType; import org.jooq.impl.TableImpl; @@ -182,6 +193,146 @@ public class Customer extends TableImpl { return _address; } + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment one-to-many child table. + */ + public Field> paymentMultiset() { + return paymentMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment one-to-many child table. + */ + public Field> paymentMultiset(Function> subquery) { + return oneToManyMultiset(Keys.PAYMENT__PAYMENT_CUSTOMER_ID_FKEY, t -> subquery.apply((Payment) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_01 one-to-many child + * table. + */ + public Field> paymentP2007_01Multiset() { + return paymentP2007_01Multiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_01 one-to-many child + * table. + */ + public Field> paymentP2007_01Multiset(Function> subquery) { + return oneToManyMultiset(Keys.PAYMENT_P2007_01__PAYMENT_P2007_01_CUSTOMER_ID_FKEY, t -> subquery.apply((PaymentP2007_01) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_02 one-to-many child + * table. + */ + public Field> paymentP2007_02Multiset() { + return paymentP2007_02Multiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_02 one-to-many child + * table. + */ + public Field> paymentP2007_02Multiset(Function> subquery) { + return oneToManyMultiset(Keys.PAYMENT_P2007_02__PAYMENT_P2007_02_CUSTOMER_ID_FKEY, t -> subquery.apply((PaymentP2007_02) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_03 one-to-many child + * table. + */ + public Field> paymentP2007_03Multiset() { + return paymentP2007_03Multiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_03 one-to-many child + * table. + */ + public Field> paymentP2007_03Multiset(Function> subquery) { + return oneToManyMultiset(Keys.PAYMENT_P2007_03__PAYMENT_P2007_03_CUSTOMER_ID_FKEY, t -> subquery.apply((PaymentP2007_03) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_04 one-to-many child + * table. + */ + public Field> paymentP2007_04Multiset() { + return paymentP2007_04Multiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_04 one-to-many child + * table. + */ + public Field> paymentP2007_04Multiset(Function> subquery) { + return oneToManyMultiset(Keys.PAYMENT_P2007_04__PAYMENT_P2007_04_CUSTOMER_ID_FKEY, t -> subquery.apply((PaymentP2007_04) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_05 one-to-many child + * table. + */ + public Field> paymentP2007_05Multiset() { + return paymentP2007_05Multiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_05 one-to-many child + * table. + */ + public Field> paymentP2007_05Multiset(Function> subquery) { + return oneToManyMultiset(Keys.PAYMENT_P2007_05__PAYMENT_P2007_05_CUSTOMER_ID_FKEY, t -> subquery.apply((PaymentP2007_05) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_06 one-to-many child + * table. + */ + public Field> paymentP2007_06Multiset() { + return paymentP2007_06Multiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_06 one-to-many child + * table. + */ + public Field> paymentP2007_06Multiset(Function> subquery) { + return oneToManyMultiset(Keys.PAYMENT_P2007_06__PAYMENT_P2007_06_CUSTOMER_ID_FKEY, t -> subquery.apply((PaymentP2007_06) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.rental one-to-many child table. + */ + public Field> rentalMultiset() { + return rentalMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.rental one-to-many child table. + */ + public Field> rentalMultiset(Function> subquery) { + return oneToManyMultiset(Keys.RENTAL__RENTAL_CUSTOMER_ID_FKEY, t -> subquery.apply((Rental) t)); + } + @Override public Customer as(String alias) { return new Customer(DSL.name(alias), this); diff --git a/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Film.java b/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Film.java index a429a10da3..0cdc128b33 100644 --- a/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Film.java +++ b/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Film.java @@ -8,6 +8,7 @@ import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.Arrays; import java.util.List; +import java.util.function.Function; import org.jooq.Field; import org.jooq.ForeignKey; @@ -15,17 +16,25 @@ import org.jooq.Identity; import org.jooq.Index; import org.jooq.Name; import org.jooq.Record; +import org.jooq.Result; import org.jooq.Row14; import org.jooq.Schema; import org.jooq.Table; import org.jooq.TableField; +import org.jooq.TableLike; import org.jooq.TableOptions; import org.jooq.UniqueKey; import org.jooq.example.testcontainers.db.Indexes; import org.jooq.example.testcontainers.db.Keys; import org.jooq.example.testcontainers.db.Public; import org.jooq.example.testcontainers.db.enums.MpaaRating; +import org.jooq.example.testcontainers.db.tables.records.ActorRecord; +import org.jooq.example.testcontainers.db.tables.records.CategoryRecord; +import org.jooq.example.testcontainers.db.tables.records.FilmActorRecord; +import org.jooq.example.testcontainers.db.tables.records.FilmCategoryRecord; import org.jooq.example.testcontainers.db.tables.records.FilmRecord; +import org.jooq.example.testcontainers.db.tables.records.InventoryRecord; +import org.jooq.example.testcontainers.db.tables.records.StoreRecord; import org.jooq.impl.DSL; import org.jooq.impl.SQLDataType; import org.jooq.impl.TableImpl; @@ -211,6 +220,106 @@ public class Film extends TableImpl { return _filmOriginalLanguageIdFkey; } + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.film_actor one-to-many child + * table. + */ + public Field> filmActorMultiset() { + return filmActorMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.film_actor one-to-many child + * table. + */ + public Field> filmActorMultiset(Function> subquery) { + return oneToManyMultiset(Keys.FILM_ACTOR__FILM_ACTOR_FILM_ID_FKEY, t -> subquery.apply((FilmActor) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.film_category one-to-many child + * table. + */ + public Field> filmCategoryMultiset() { + return filmCategoryMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.film_category one-to-many child + * table. + */ + public Field> filmCategoryMultiset(Function> subquery) { + return oneToManyMultiset(Keys.FILM_CATEGORY__FILM_CATEGORY_FILM_ID_FKEY, t -> subquery.apply((FilmCategory) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.inventory one-to-many child table. + */ + public Field> inventoryMultiset() { + return inventoryMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.inventory one-to-many child table. + */ + public Field> inventoryMultiset(Function> subquery) { + return oneToManyMultiset(Keys.INVENTORY__INVENTORY_FILM_ID_FKEY, t -> subquery.apply((Inventory) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.actor many-to-many child table. + */ + public Field> actorMultiset() { + return actorMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.actor many-to-many child table. + */ + public Field> actorMultiset(Function> subquery) { + return manyToManyMultiset(Keys.FILM_ACTOR__FILM_ACTOR_FILM_ID_FKEY, Keys.FILM_ACTOR__FILM_ACTOR_ACTOR_ID_FKEY, t -> subquery.apply((Actor) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.category many-to-many child table. + */ + public Field> categoryMultiset() { + return categoryMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.category many-to-many child table. + */ + public Field> categoryMultiset(Function> subquery) { + return manyToManyMultiset(Keys.FILM_CATEGORY__FILM_CATEGORY_FILM_ID_FKEY, Keys.FILM_CATEGORY__FILM_CATEGORY_CATEGORY_ID_FKEY, t -> subquery.apply((Category) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.store many-to-many child table. + */ + public Field> storeMultiset() { + return storeMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.store many-to-many child table. + */ + public Field> storeMultiset(Function> subquery) { + return manyToManyMultiset(Keys.INVENTORY__INVENTORY_FILM_ID_FKEY, Keys.INVENTORY__INVENTORY_STORE_ID_FKEY, t -> subquery.apply((Store) t)); + } + @Override public Film as(String alias) { return new Film(DSL.name(alias), this); diff --git a/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Inventory.java b/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Inventory.java index 4261da7fb4..5305a06d09 100644 --- a/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Inventory.java +++ b/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Inventory.java @@ -7,6 +7,7 @@ package org.jooq.example.testcontainers.db.tables; import java.time.LocalDateTime; import java.util.Arrays; import java.util.List; +import java.util.function.Function; import org.jooq.Field; import org.jooq.ForeignKey; @@ -14,16 +15,21 @@ import org.jooq.Identity; import org.jooq.Index; import org.jooq.Name; import org.jooq.Record; +import org.jooq.Result; import org.jooq.Row4; import org.jooq.Schema; import org.jooq.Table; import org.jooq.TableField; +import org.jooq.TableLike; import org.jooq.TableOptions; import org.jooq.UniqueKey; import org.jooq.example.testcontainers.db.Indexes; import org.jooq.example.testcontainers.db.Keys; import org.jooq.example.testcontainers.db.Public; +import org.jooq.example.testcontainers.db.tables.records.CustomerRecord; import org.jooq.example.testcontainers.db.tables.records.InventoryRecord; +import org.jooq.example.testcontainers.db.tables.records.RentalRecord; +import org.jooq.example.testcontainers.db.tables.records.StaffRecord; import org.jooq.impl.DSL; import org.jooq.impl.SQLDataType; import org.jooq.impl.TableImpl; @@ -151,6 +157,54 @@ public class Inventory extends TableImpl { return _store; } + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.rental one-to-many child table. + */ + public Field> rentalMultiset() { + return rentalMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.rental one-to-many child table. + */ + public Field> rentalMultiset(Function> subquery) { + return oneToManyMultiset(Keys.RENTAL__RENTAL_INVENTORY_ID_FKEY, t -> subquery.apply((Rental) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.customer many-to-many child table. + */ + public Field> customerMultiset() { + return customerMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.customer many-to-many child table. + */ + public Field> customerMultiset(Function> subquery) { + return manyToManyMultiset(Keys.RENTAL__RENTAL_INVENTORY_ID_FKEY, Keys.RENTAL__RENTAL_CUSTOMER_ID_FKEY, t -> subquery.apply((Customer) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.staff many-to-many child table. + */ + public Field> staffMultiset() { + return staffMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.staff many-to-many child table. + */ + public Field> staffMultiset(Function> subquery) { + return manyToManyMultiset(Keys.RENTAL__RENTAL_INVENTORY_ID_FKEY, Keys.RENTAL__RENTAL_STAFF_ID_FKEY, t -> subquery.apply((Staff) t)); + } + @Override public Inventory as(String alias) { return new Inventory(DSL.name(alias), this); diff --git a/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Language.java b/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Language.java index b4f588d35a..102c39a764 100644 --- a/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Language.java +++ b/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Language.java @@ -5,16 +5,19 @@ package org.jooq.example.testcontainers.db.tables; import java.time.LocalDateTime; +import java.util.function.Function; import org.jooq.Field; import org.jooq.ForeignKey; import org.jooq.Identity; import org.jooq.Name; import org.jooq.Record; +import org.jooq.Result; import org.jooq.Row3; import org.jooq.Schema; import org.jooq.Table; import org.jooq.TableField; +import org.jooq.TableLike; import org.jooq.TableOptions; import org.jooq.UniqueKey; import org.jooq.example.testcontainers.db.Keys; @@ -109,6 +112,38 @@ public class Language extends TableImpl { return Keys.LANGUAGE_PKEY; } + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.language many-to-many child table. + */ + public Field> filmOriginalLanguageIdFkeyMultiset() { + return filmOriginalLanguageIdFkeyMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.language many-to-many child table. + */ + public Field> filmOriginalLanguageIdFkeyMultiset(Function> subquery) { + return manyToManyMultiset(Keys.FILM__FILM_LANGUAGE_ID_FKEY, Keys.FILM__FILM_ORIGINAL_LANGUAGE_ID_FKEY, t -> subquery.apply((Language) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.language many-to-many child table. + */ + public Field> filmLanguageIdFkeyMultiset() { + return filmLanguageIdFkeyMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.language many-to-many child table. + */ + public Field> filmLanguageIdFkeyMultiset(Function> subquery) { + return manyToManyMultiset(Keys.FILM__FILM_ORIGINAL_LANGUAGE_ID_FKEY, Keys.FILM__FILM_LANGUAGE_ID_FKEY, t -> subquery.apply((Language) t)); + } + @Override public Language as(String alias) { return new Language(DSL.name(alias), this); diff --git a/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Rental.java b/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Rental.java index 558c97f0b9..1e3d91c2e5 100644 --- a/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Rental.java +++ b/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Rental.java @@ -7,6 +7,7 @@ package org.jooq.example.testcontainers.db.tables; import java.time.LocalDateTime; import java.util.Arrays; import java.util.List; +import java.util.function.Function; import org.jooq.Field; import org.jooq.ForeignKey; @@ -14,15 +15,24 @@ import org.jooq.Identity; import org.jooq.Index; import org.jooq.Name; import org.jooq.Record; +import org.jooq.Result; import org.jooq.Row7; import org.jooq.Schema; import org.jooq.Table; import org.jooq.TableField; +import org.jooq.TableLike; import org.jooq.TableOptions; import org.jooq.UniqueKey; import org.jooq.example.testcontainers.db.Indexes; import org.jooq.example.testcontainers.db.Keys; import org.jooq.example.testcontainers.db.Public; +import org.jooq.example.testcontainers.db.tables.records.PaymentP2007_01Record; +import org.jooq.example.testcontainers.db.tables.records.PaymentP2007_02Record; +import org.jooq.example.testcontainers.db.tables.records.PaymentP2007_03Record; +import org.jooq.example.testcontainers.db.tables.records.PaymentP2007_04Record; +import org.jooq.example.testcontainers.db.tables.records.PaymentP2007_05Record; +import org.jooq.example.testcontainers.db.tables.records.PaymentP2007_06Record; +import org.jooq.example.testcontainers.db.tables.records.PaymentRecord; import org.jooq.example.testcontainers.db.tables.records.RentalRecord; import org.jooq.impl.DSL; import org.jooq.impl.SQLDataType; @@ -177,6 +187,130 @@ public class Rental extends TableImpl { return _staff; } + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment one-to-many child table. + */ + public Field> paymentMultiset() { + return paymentMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment one-to-many child table. + */ + public Field> paymentMultiset(Function> subquery) { + return oneToManyMultiset(Keys.PAYMENT__PAYMENT_RENTAL_ID_FKEY, t -> subquery.apply((Payment) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_01 one-to-many child + * table. + */ + public Field> paymentP2007_01Multiset() { + return paymentP2007_01Multiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_01 one-to-many child + * table. + */ + public Field> paymentP2007_01Multiset(Function> subquery) { + return oneToManyMultiset(Keys.PAYMENT_P2007_01__PAYMENT_P2007_01_RENTAL_ID_FKEY, t -> subquery.apply((PaymentP2007_01) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_02 one-to-many child + * table. + */ + public Field> paymentP2007_02Multiset() { + return paymentP2007_02Multiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_02 one-to-many child + * table. + */ + public Field> paymentP2007_02Multiset(Function> subquery) { + return oneToManyMultiset(Keys.PAYMENT_P2007_02__PAYMENT_P2007_02_RENTAL_ID_FKEY, t -> subquery.apply((PaymentP2007_02) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_03 one-to-many child + * table. + */ + public Field> paymentP2007_03Multiset() { + return paymentP2007_03Multiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_03 one-to-many child + * table. + */ + public Field> paymentP2007_03Multiset(Function> subquery) { + return oneToManyMultiset(Keys.PAYMENT_P2007_03__PAYMENT_P2007_03_RENTAL_ID_FKEY, t -> subquery.apply((PaymentP2007_03) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_04 one-to-many child + * table. + */ + public Field> paymentP2007_04Multiset() { + return paymentP2007_04Multiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_04 one-to-many child + * table. + */ + public Field> paymentP2007_04Multiset(Function> subquery) { + return oneToManyMultiset(Keys.PAYMENT_P2007_04__PAYMENT_P2007_04_RENTAL_ID_FKEY, t -> subquery.apply((PaymentP2007_04) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_05 one-to-many child + * table. + */ + public Field> paymentP2007_05Multiset() { + return paymentP2007_05Multiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_05 one-to-many child + * table. + */ + public Field> paymentP2007_05Multiset(Function> subquery) { + return oneToManyMultiset(Keys.PAYMENT_P2007_05__PAYMENT_P2007_05_RENTAL_ID_FKEY, t -> subquery.apply((PaymentP2007_05) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_06 one-to-many child + * table. + */ + public Field> paymentP2007_06Multiset() { + return paymentP2007_06Multiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_06 one-to-many child + * table. + */ + public Field> paymentP2007_06Multiset(Function> subquery) { + return oneToManyMultiset(Keys.PAYMENT_P2007_06__PAYMENT_P2007_06_RENTAL_ID_FKEY, t -> subquery.apply((PaymentP2007_06) t)); + } + @Override public Rental as(String alias) { return new Rental(DSL.name(alias), this); diff --git a/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Staff.java b/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Staff.java index 76074198dd..1a0e201816 100644 --- a/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Staff.java +++ b/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Staff.java @@ -7,21 +7,33 @@ package org.jooq.example.testcontainers.db.tables; import java.time.LocalDateTime; import java.util.Arrays; import java.util.List; +import java.util.function.Function; import org.jooq.Field; import org.jooq.ForeignKey; import org.jooq.Identity; import org.jooq.Name; import org.jooq.Record; +import org.jooq.Result; import org.jooq.Row11; import org.jooq.Schema; import org.jooq.Table; import org.jooq.TableField; +import org.jooq.TableLike; import org.jooq.TableOptions; import org.jooq.UniqueKey; import org.jooq.example.testcontainers.db.Keys; import org.jooq.example.testcontainers.db.Public; +import org.jooq.example.testcontainers.db.tables.records.PaymentP2007_01Record; +import org.jooq.example.testcontainers.db.tables.records.PaymentP2007_02Record; +import org.jooq.example.testcontainers.db.tables.records.PaymentP2007_03Record; +import org.jooq.example.testcontainers.db.tables.records.PaymentP2007_04Record; +import org.jooq.example.testcontainers.db.tables.records.PaymentP2007_05Record; +import org.jooq.example.testcontainers.db.tables.records.PaymentP2007_06Record; +import org.jooq.example.testcontainers.db.tables.records.PaymentRecord; +import org.jooq.example.testcontainers.db.tables.records.RentalRecord; import org.jooq.example.testcontainers.db.tables.records.StaffRecord; +import org.jooq.example.testcontainers.db.tables.records.StoreRecord; import org.jooq.impl.DSL; import org.jooq.impl.SQLDataType; import org.jooq.impl.TableImpl; @@ -179,6 +191,162 @@ public class Staff extends TableImpl { return _store; } + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment one-to-many child table. + */ + public Field> paymentMultiset() { + return paymentMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment one-to-many child table. + */ + public Field> paymentMultiset(Function> subquery) { + return oneToManyMultiset(Keys.PAYMENT__PAYMENT_STAFF_ID_FKEY, t -> subquery.apply((Payment) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_01 one-to-many child + * table. + */ + public Field> paymentP2007_01Multiset() { + return paymentP2007_01Multiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_01 one-to-many child + * table. + */ + public Field> paymentP2007_01Multiset(Function> subquery) { + return oneToManyMultiset(Keys.PAYMENT_P2007_01__PAYMENT_P2007_01_STAFF_ID_FKEY, t -> subquery.apply((PaymentP2007_01) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_02 one-to-many child + * table. + */ + public Field> paymentP2007_02Multiset() { + return paymentP2007_02Multiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_02 one-to-many child + * table. + */ + public Field> paymentP2007_02Multiset(Function> subquery) { + return oneToManyMultiset(Keys.PAYMENT_P2007_02__PAYMENT_P2007_02_STAFF_ID_FKEY, t -> subquery.apply((PaymentP2007_02) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_03 one-to-many child + * table. + */ + public Field> paymentP2007_03Multiset() { + return paymentP2007_03Multiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_03 one-to-many child + * table. + */ + public Field> paymentP2007_03Multiset(Function> subquery) { + return oneToManyMultiset(Keys.PAYMENT_P2007_03__PAYMENT_P2007_03_STAFF_ID_FKEY, t -> subquery.apply((PaymentP2007_03) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_04 one-to-many child + * table. + */ + public Field> paymentP2007_04Multiset() { + return paymentP2007_04Multiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_04 one-to-many child + * table. + */ + public Field> paymentP2007_04Multiset(Function> subquery) { + return oneToManyMultiset(Keys.PAYMENT_P2007_04__PAYMENT_P2007_04_STAFF_ID_FKEY, t -> subquery.apply((PaymentP2007_04) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_05 one-to-many child + * table. + */ + public Field> paymentP2007_05Multiset() { + return paymentP2007_05Multiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_05 one-to-many child + * table. + */ + public Field> paymentP2007_05Multiset(Function> subquery) { + return oneToManyMultiset(Keys.PAYMENT_P2007_05__PAYMENT_P2007_05_STAFF_ID_FKEY, t -> subquery.apply((PaymentP2007_05) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_06 one-to-many child + * table. + */ + public Field> paymentP2007_06Multiset() { + return paymentP2007_06Multiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.payment_p2007_06 one-to-many child + * table. + */ + public Field> paymentP2007_06Multiset(Function> subquery) { + return oneToManyMultiset(Keys.PAYMENT_P2007_06__PAYMENT_P2007_06_STAFF_ID_FKEY, t -> subquery.apply((PaymentP2007_06) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.rental one-to-many child table. + */ + public Field> rentalMultiset() { + return rentalMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.rental one-to-many child table. + */ + public Field> rentalMultiset(Function> subquery) { + return oneToManyMultiset(Keys.RENTAL__RENTAL_STAFF_ID_FKEY, t -> subquery.apply((Rental) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.store one-to-many child table. + */ + public Field> storeMultiset() { + return storeMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.store one-to-many child table. + */ + public Field> storeMultiset(Function> subquery) { + return oneToManyMultiset(Keys.STORE__STORE_MANAGER_STAFF_ID_FKEY, t -> subquery.apply((Store) t)); + } + @Override public Staff as(String alias) { return new Staff(DSL.name(alias), this); diff --git a/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Store.java b/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Store.java index 95af211e16..1f65dffd73 100644 --- a/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Store.java +++ b/jOOQ-examples/jOOQ-testcontainers-example/src/main/java/org/jooq/example/testcontainers/db/tables/Store.java @@ -7,6 +7,7 @@ package org.jooq.example.testcontainers.db.tables; import java.time.LocalDateTime; import java.util.Arrays; import java.util.List; +import java.util.function.Function; import org.jooq.Field; import org.jooq.ForeignKey; @@ -14,15 +15,20 @@ import org.jooq.Identity; import org.jooq.Index; import org.jooq.Name; import org.jooq.Record; +import org.jooq.Result; import org.jooq.Row4; import org.jooq.Schema; import org.jooq.Table; import org.jooq.TableField; +import org.jooq.TableLike; import org.jooq.TableOptions; import org.jooq.UniqueKey; import org.jooq.example.testcontainers.db.Indexes; import org.jooq.example.testcontainers.db.Keys; import org.jooq.example.testcontainers.db.Public; +import org.jooq.example.testcontainers.db.tables.records.CustomerRecord; +import org.jooq.example.testcontainers.db.tables.records.InventoryRecord; +import org.jooq.example.testcontainers.db.tables.records.StaffRecord; import org.jooq.example.testcontainers.db.tables.records.StoreRecord; import org.jooq.impl.DSL; import org.jooq.impl.SQLDataType; @@ -151,6 +157,54 @@ public class Store extends TableImpl { return _address; } + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.customer one-to-many child table. + */ + public Field> customerMultiset() { + return customerMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.customer one-to-many child table. + */ + public Field> customerMultiset(Function> subquery) { + return oneToManyMultiset(Keys.CUSTOMER__CUSTOMER_STORE_ID_FKEY, t -> subquery.apply((Customer) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.inventory one-to-many child table. + */ + public Field> inventoryMultiset() { + return inventoryMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.inventory one-to-many child table. + */ + public Field> inventoryMultiset(Function> subquery) { + return oneToManyMultiset(Keys.INVENTORY__INVENTORY_STORE_ID_FKEY, t -> subquery.apply((Inventory) t)); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.staff one-to-many child table. + */ + public Field> staffMultiset() { + return staffMultiset(Function.identity()); + } + + /** + * A convenience constructor for correlated MULTISETs + * expressions to the public.staff one-to-many child table. + */ + public Field> staffMultiset(Function> subquery) { + return oneToManyMultiset(Keys.STAFF__STAFF_STORE_ID_FKEY, t -> subquery.apply((Staff) t)); + } + @Override public Store as(String alias) { return new Store(DSL.name(alias), this); diff --git a/jOOQ-examples/jOOQ-testcontainers-example/src/test/java/org/jooq/example/test/containers/TestContainersTest.java b/jOOQ-examples/jOOQ-testcontainers-example/src/test/java/org/jooq/example/test/containers/TestContainersTest.java index e720b37e84..63ae03e70a 100644 --- a/jOOQ-examples/jOOQ-testcontainers-example/src/test/java/org/jooq/example/test/containers/TestContainersTest.java +++ b/jOOQ-examples/jOOQ-testcontainers-example/src/test/java/org/jooq/example/test/containers/TestContainersTest.java @@ -1,12 +1,16 @@ package org.jooq.example.test.containers; -import org.jooq.*; -import org.jooq.example.testcontainers.db.Tables; -import org.jooq.impl.DSL; -import org.jooq.tools.JooqLogger; -import org.junit.BeforeClass; -import org.junit.Test; -import org.testcontainers.jdbc.ContainerDatabaseDriver; +import static org.jooq.JSONFormat.RecordFormat.OBJECT; +import static org.jooq.Records.mapping; +import static org.jooq.XMLFormat.RecordFormat.COLUMN_NAME_ELEMENTS; +import static org.jooq.example.testcontainers.db.Tables.FILM; +import static org.jooq.example.testcontainers.db.Tables.FILM_ACTOR; +import static org.jooq.example.testcontainers.db.Tables.FILM_CATEGORY; +import static org.jooq.example.testcontainers.db.Tables.PAYMENT; +import static org.jooq.impl.DSL.multiset; +import static org.jooq.impl.DSL.multisetAgg; +import static org.jooq.impl.DSL.select; +import static org.jooq.impl.DSL.sum; import java.sql.Connection; import java.sql.SQLException; @@ -14,11 +18,19 @@ import java.sql.Statement; import java.util.Arrays; import java.util.Properties; -import static org.jooq.JSONFormat.RecordFormat.OBJECT; -import static org.jooq.Records.mapping; -import static org.jooq.XMLFormat.RecordFormat.COLUMN_NAME_ELEMENTS; -import static org.jooq.example.testcontainers.db.Tables.*; -import static org.jooq.impl.DSL.*; +import org.jooq.DSLContext; +import org.jooq.JSONFormat; +import org.jooq.Result; +import org.jooq.SQLDialect; +import org.jooq.Source; +import org.jooq.TXTFormat; +import org.jooq.XMLFormat; +import org.jooq.impl.DSL; +import org.jooq.tools.JooqLogger; + +import org.junit.BeforeClass; +import org.junit.Test; +import org.testcontainers.jdbc.ContainerDatabaseDriver; public class TestContainersTest { diff --git a/jOOQ-meta/src/main/java/org/jooq/meta/jaxb/Generate.java b/jOOQ-meta/src/main/java/org/jooq/meta/jaxb/Generate.java index 6806ca974a..b4b3f33f3f 100644 --- a/jOOQ-meta/src/main/java/org/jooq/meta/jaxb/Generate.java +++ b/jOOQ-meta/src/main/java/org/jooq/meta/jaxb/Generate.java @@ -39,6 +39,12 @@ public class Generate implements Serializable, XMLAppendable @XmlElement(defaultValue = "true") protected Boolean implicitJoinPathsToOne = true; @XmlElement(defaultValue = "true") + protected Boolean rowConvenienceToOne = true; + @XmlElement(defaultValue = "true") + protected Boolean multisetConvenienceOneToMany = true; + @XmlElement(defaultValue = "true") + protected Boolean multisetConvenienceManyToMany = true; + @XmlElement(defaultValue = "true") protected Boolean deprecated = true; @XmlElement(defaultValue = "true") protected Boolean deprecationOnUnknownTypes = true; @@ -311,6 +317,84 @@ public class Generate implements Serializable, XMLAppendable this.implicitJoinPathsToOne = value; } + /** + * Generate ROW convenience syntax for to-one relationships. + *

+ * This feature is available in the commercial distribution only. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isRowConvenienceToOne() { + return rowConvenienceToOne; + } + + /** + * Sets the value of the rowConvenienceToOne property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setRowConvenienceToOne(Boolean value) { + this.rowConvenienceToOne = value; + } + + /** + * Generate MULTISET convenience syntax for one-to-many relationships. + *

+ * This feature is available in the commercial distribution only. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isMultisetConvenienceOneToMany() { + return multisetConvenienceOneToMany; + } + + /** + * Sets the value of the multisetConvenienceOneToMany property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setMultisetConvenienceOneToMany(Boolean value) { + this.multisetConvenienceOneToMany = value; + } + + /** + * Generate MULTISET convenience syntax for many-to-many relationships. A many-to-many relationship is achieved when a child table has 2 non-nullable foreign keys that are part of a unique key. + *

+ * This feature is available in the commercial distribution only. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isMultisetConvenienceManyToMany() { + return multisetConvenienceManyToMany; + } + + /** + * Sets the value of the multisetConvenienceManyToMany property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setMultisetConvenienceManyToMany(Boolean value) { + this.multisetConvenienceManyToMany = value; + } + /** * Generate deprecated code for backwards compatibility * @@ -2322,6 +2406,21 @@ public class Generate implements Serializable, XMLAppendable return this; } + public Generate withRowConvenienceToOne(Boolean value) { + setRowConvenienceToOne(value); + return this; + } + + public Generate withMultisetConvenienceOneToMany(Boolean value) { + setMultisetConvenienceOneToMany(value); + return this; + } + + public Generate withMultisetConvenienceManyToMany(Boolean value) { + setMultisetConvenienceManyToMany(value); + return this; + } + public Generate withDeprecated(Boolean value) { setDeprecated(value); return this; @@ -2802,6 +2901,9 @@ public class Generate implements Serializable, XMLAppendable builder.append("relations", relations); builder.append("sequenceFlags", sequenceFlags); builder.append("implicitJoinPathsToOne", implicitJoinPathsToOne); + builder.append("rowConvenienceToOne", rowConvenienceToOne); + builder.append("multisetConvenienceOneToMany", multisetConvenienceOneToMany); + builder.append("multisetConvenienceManyToMany", multisetConvenienceManyToMany); builder.append("deprecated", deprecated); builder.append("deprecationOnUnknownTypes", deprecationOnUnknownTypes); builder.append("instanceFields", instanceFields); @@ -2944,6 +3046,33 @@ public class Generate implements Serializable, XMLAppendable return false; } } + if (rowConvenienceToOne == null) { + if (other.rowConvenienceToOne!= null) { + return false; + } + } else { + if (!rowConvenienceToOne.equals(other.rowConvenienceToOne)) { + return false; + } + } + if (multisetConvenienceOneToMany == null) { + if (other.multisetConvenienceOneToMany!= null) { + return false; + } + } else { + if (!multisetConvenienceOneToMany.equals(other.multisetConvenienceOneToMany)) { + return false; + } + } + if (multisetConvenienceManyToMany == null) { + if (other.multisetConvenienceManyToMany!= null) { + return false; + } + } else { + if (!multisetConvenienceManyToMany.equals(other.multisetConvenienceManyToMany)) { + return false; + } + } if (deprecated == null) { if (other.deprecated!= null) { return false; @@ -3720,6 +3849,9 @@ public class Generate implements Serializable, XMLAppendable result = ((prime*result)+((relations == null)? 0 :relations.hashCode())); result = ((prime*result)+((sequenceFlags == null)? 0 :sequenceFlags.hashCode())); result = ((prime*result)+((implicitJoinPathsToOne == null)? 0 :implicitJoinPathsToOne.hashCode())); + result = ((prime*result)+((rowConvenienceToOne == null)? 0 :rowConvenienceToOne.hashCode())); + result = ((prime*result)+((multisetConvenienceOneToMany == null)? 0 :multisetConvenienceOneToMany.hashCode())); + result = ((prime*result)+((multisetConvenienceManyToMany == null)? 0 :multisetConvenienceManyToMany.hashCode())); result = ((prime*result)+((deprecated == null)? 0 :deprecated.hashCode())); result = ((prime*result)+((deprecationOnUnknownTypes == null)? 0 :deprecationOnUnknownTypes.hashCode())); result = ((prime*result)+((instanceFields == null)? 0 :instanceFields.hashCode())); diff --git a/jOOQ-meta/src/main/resources/org/jooq/meta/xsd/jooq-codegen-3.17.0.xsd b/jOOQ-meta/src/main/resources/org/jooq/meta/xsd/jooq-codegen-3.17.0.xsd index 08358017d1..f7d08855c0 100644 --- a/jOOQ-meta/src/main/resources/org/jooq/meta/xsd/jooq-codegen-3.17.0.xsd +++ b/jOOQ-meta/src/main/resources/org/jooq/meta/xsd/jooq-codegen-3.17.0.xsd @@ -1582,6 +1582,24 @@ This is a prerequisite for various advanced features]]> + + + ROW convenience syntax for to-one relationships. +

+This feature is available in the commercial distribution only.]]> + + + + MULTISET convenience syntax for one-to-many relationships. +

+This feature is available in the commercial distribution only.]]> + + + + MULTISET convenience syntax for many-to-many relationships. A many-to-many relationship is achieved when a child table has 2 non-nullable foreign keys that are part of a unique key. +

+This feature is available in the commercial distribution only.]]> + diff --git a/jOOQ/src/main/java/org/jooq/impl/TableImpl.java b/jOOQ/src/main/java/org/jooq/impl/TableImpl.java index 57b5e56079..49236d9364 100644 --- a/jOOQ/src/main/java/org/jooq/impl/TableImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/TableImpl.java @@ -45,45 +45,62 @@ import static org.jooq.Clause.TABLE_REFERENCE; // ... // ... // ... +// ... import static org.jooq.SQLDialect.FIREBIRD; +import static org.jooq.SQLDialect.H2; import static org.jooq.SQLDialect.HSQLDB; // ... +import static org.jooq.SQLDialect.MARIADB; +import static org.jooq.SQLDialect.MYSQL; +// ... // ... import static org.jooq.SQLDialect.POSTGRES; import static org.jooq.SQLDialect.YUGABYTEDB; +import static org.jooq.impl.DSL.and; +import static org.jooq.impl.DSL.multiset; +import static org.jooq.impl.DSL.multisetAgg; +import static org.jooq.impl.DSL.row; +import static org.jooq.impl.DSL.select; +import static org.jooq.impl.DSL.selectFrom; import static org.jooq.impl.DefaultMetaProvider.meta; import static org.jooq.impl.Internal.createPathAlias; import static org.jooq.impl.Keywords.K_TABLE; +import static org.jooq.impl.Names.N_MULTISET; import static org.jooq.impl.QueryPartListView.wrap; import static org.jooq.impl.SchemaImpl.DEFAULT_SCHEMA; import static org.jooq.impl.Tools.EMPTY_OBJECT; import static org.jooq.impl.Tools.getMappedTable; import static org.jooq.tools.StringUtils.defaultIfNull; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.Set; -import java.util.function.BiFunction; -import java.util.function.Predicate; +import java.util.function.Function; import java.util.stream.Stream; import org.jooq.Clause; import org.jooq.Comment; +import org.jooq.Condition; import org.jooq.Context; import org.jooq.Field; import org.jooq.ForeignKey; -import org.jooq.Function1; import org.jooq.Name; // ... import org.jooq.QueryPart; import org.jooq.Record; // ... +import org.jooq.Result; import org.jooq.Row; import org.jooq.SQLDialect; import org.jooq.Schema; import org.jooq.Select; import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.TableLike; import org.jooq.TableOptions; // ... +import org.jooq.impl.QOM.UEmptyField; import org.jooq.impl.QOM.UNotYetImplemented; import org.jooq.tools.StringUtils; @@ -252,6 +269,121 @@ implements return null; } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /** * Check if this table already aliases another one. *