diff --git a/jOOQ-examples/jOOQ-jpa-example-entities/pom.xml b/jOOQ-examples/jOOQ-jpa-example-entities/pom.xml index 7d5ff58ae0..09bb2dd3dd 100644 --- a/jOOQ-examples/jOOQ-jpa-example-entities/pom.xml +++ b/jOOQ-examples/jOOQ-jpa-example-entities/pom.xml @@ -18,7 +18,7 @@ UTF-8 - 5.3.1.Final + 5.3.7.Final @@ -38,10 +38,6 @@ maven-compiler-plugin 3.8.0 - true - 1024m - 256m - UTF-8 10 @@ -50,14 +46,34 @@ 10 10 - true - lines,vars,source - - - -Xlint:varargs - + + + false + true + + + + + org.hibernate + hibernate-jpamodelgen + ${org.hibernate.version} + + + javax.xml.bind + jaxb-api + 2.3.0 + + + + + + javax.xml.bind + jaxb-api + 2.3.0 + + diff --git a/jOOQ-examples/jOOQ-jpa-example/pom.xml b/jOOQ-examples/jOOQ-jpa-example/pom.xml index 2f7eeb3703..3f17f45cd3 100644 --- a/jOOQ-examples/jOOQ-jpa-example/pom.xml +++ b/jOOQ-examples/jOOQ-jpa-example/pom.xml @@ -101,12 +101,12 @@ 256m UTF-8 - 10 + 11 - 10 - 10 + 11 + 11 true lines,vars,source diff --git a/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/CriteriaQueryOrJOOQ.java b/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/CriteriaQueryOrJOOQ.java new file mode 100644 index 0000000000..91ca1a0995 --- /dev/null +++ b/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/CriteriaQueryOrJOOQ.java @@ -0,0 +1,164 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Other licenses: + * ----------------------------------------------------------------------------- + * Commercial licenses for this work are available. These replace the above + * ASL 2.0 and offer limited warranties, support, maintenance, and commercial + * database integrations. + * + * For more information, please visit: http://www.jooq.org/licenses + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + */ +package org.jooq.example.jpa; + +import static org.jooq.example.jpa.jooq.Tables.FILM; +import static org.jooq.example.jpa.jooq.Tables.FILM_ACTOR; +import static org.jooq.example.jpa.jooq.Tables.LANGUAGE; +import static org.jooq.impl.DSL.count; +import static org.jooq.impl.DSL.countDistinct; + +import javax.persistence.EntityManager; +import javax.persistence.Tuple; +import javax.persistence.TypedQuery; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Expression; +import javax.persistence.criteria.Join; +import javax.persistence.criteria.Path; +import javax.persistence.criteria.Root; +import javax.persistence.criteria.SetJoin; + +import org.jooq.DSLContext; +import org.jooq.example.jpa.entity.Actor; +import org.jooq.example.jpa.entity.Actor_; +import org.jooq.example.jpa.entity.Film; +import org.jooq.example.jpa.entity.Film_; +import org.jooq.example.jpa.entity.Language; +import org.jooq.example.jpa.entity.Language_; + +/** + * @author Lukas Eder + */ +class CriteriaQueryOrJOOQ { + + private static void run(EntityManager em, DSLContext ctx) { + filmLengthAndLanguages(em, ctx); + numberOfFilmsPerLanguage(em, ctx); + numberOfActorsPerLanguage(em, ctx); + } + + private static void filmLengthAndLanguages(EntityManager em, DSLContext ctx) { + // Using criteria query + // -------------------- + + CriteriaBuilder qb = em.getCriteriaBuilder(); + CriteriaQuery q = qb.createQuery(Film.class); + Root root = q.from(Film.class); + q = q.select(root); + TypedQuery typed = em.createQuery(q); + + for (Film film : typed.getResultList()) + System.out.println(film.title.value + " (" + film.length + " minutes) in " + film.language.name); + + // Using jOOQ + // ---------- + + for (var rec : + ctx.select(FILM.TITLE, FILM.LENGTH, LANGUAGE.NAME) + .from(FILM) + .join(LANGUAGE).on(FILM.LANGUAGE_LANGUAGEID.eq(LANGUAGE.LANGUAGEID))) + System.out.println(rec.get(FILM.TITLE) + " (" + rec.get(FILM.LENGTH) + " minutes) in " + rec.get(LANGUAGE.NAME)); + } + + private static void numberOfFilmsPerLanguage(EntityManager em, DSLContext ctx) { + + // Using criteria query + // -------------------- + + CriteriaBuilder qb = em.getCriteriaBuilder(); + CriteriaQuery q = qb.createTupleQuery(); + Root filmRoot = q.from(Film.class); + Join filmJoin = filmRoot.join(Film_.language); + Path languagePath = filmJoin.get(Language_.name); + Path filmPath = filmRoot.get(Film_.filmId); + Expression count = qb.count(filmPath); + q = q.multiselect(languagePath, count); + q = q.groupBy(languagePath); + TypedQuery typed = em.createQuery(q); + + for (Tuple tuple : typed.getResultList()) + System.out.println(tuple.get(languagePath) + " (" + tuple.get(count) + " films)"); + + // Using jOOQ + // ---------- + + for (var rec : + ctx.select(LANGUAGE.NAME, count()) + .from(LANGUAGE) + .join(FILM).on(FILM.LANGUAGE_LANGUAGEID.eq(LANGUAGE.LANGUAGEID)) + .groupBy(LANGUAGE.NAME)) + System.out.println(rec.get(LANGUAGE.NAME) + " (" + rec.get(count()) + " films)"); + } + + private static void numberOfActorsPerLanguage(EntityManager em, DSLContext ctx) { + + // Using criteria query + // -------------------- + + CriteriaBuilder qb = em.getCriteriaBuilder(); + CriteriaQuery q = qb.createTupleQuery(); + Root filmRoot = q.from(Film.class); + Join filmJoin = filmRoot.join(Film_.language); + Path languagePath = filmJoin.get(Language_.name); + SetJoin actorJoin = filmRoot.join(Film_.actors); + Path actorPath = actorJoin.get(Actor_.actorId); + Expression count = qb.countDistinct(actorPath); + q = q.multiselect(languagePath, count); + q = q.groupBy(languagePath); + TypedQuery typed = em.createQuery(q); + + for (Tuple tuple : typed.getResultList()) + System.out.println(tuple.get(languagePath) + " (" + tuple.get(count) + " actors)"); + + // Using jOOQ + // ---------- + + for (var rec : + ctx.select(LANGUAGE.NAME, countDistinct(FILM_ACTOR.ACTORS_ACTORID).as("c")) + .from(LANGUAGE) + .join(FILM).on(FILM.LANGUAGE_LANGUAGEID.eq(LANGUAGE.LANGUAGEID)) + .join(FILM_ACTOR).on(FILM.FILMID.eq(FILM_ACTOR.FILMS_FILMID)) + .groupBy(LANGUAGE.NAME)) + System.out.println(rec.get(LANGUAGE.NAME) + " (" + rec.get("c") + " actors)"); + } + + public static void main(String[] args) throws Exception { + Setup.run(CriteriaQueryOrJOOQ::run); + } +} diff --git a/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/JPAExample.java b/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/JPAExample.java index 1fb3fee817..a5c749f692 100644 --- a/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/JPAExample.java +++ b/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/JPAExample.java @@ -45,37 +45,9 @@ import static org.jooq.impl.DSL.count; import static org.jooq.impl.DSL.max; import static org.jooq.impl.DSL.min; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; -import java.time.Year; -import java.util.Arrays; -import java.util.EnumSet; - import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; import org.jooq.DSLContext; -import org.jooq.ExecuteContext; -import org.jooq.SQLDialect; -import org.jooq.example.jpa.embeddables.Title; -import org.jooq.example.jpa.entity.Actor; -import org.jooq.example.jpa.entity.Film; -import org.jooq.example.jpa.entity.Language; -import org.jooq.impl.DSL; -import org.jooq.impl.DefaultConfiguration; -import org.jooq.impl.DefaultExecuteListener; - -import org.hibernate.boot.MetadataSources; -import org.hibernate.boot.registry.StandardServiceRegistryBuilder; -import org.hibernate.cfg.AvailableSettings; -import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; -import org.hibernate.jpa.HibernatePersistenceProvider; -import org.hibernate.tool.hbm2ddl.SchemaExport; -import org.hibernate.tool.schema.TargetType; -import org.springframework.jdbc.datasource.SingleConnectionDataSource; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; /** * @author Lukas Eder @@ -83,50 +55,6 @@ import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; class JPAExample { private static void run(EntityManager em, DSLContext ctx) { - - // Set up database - // --------------- - Language english = new Language("English"); - Language german = new Language("German"); - - Actor umaThurman = new Actor("Uma", "Thurman"); - Actor davidCarradine = new Actor("David", "Carradine"); - Actor darylHannah = new Actor("Daryl", "Hannah"); - Actor michaelAngarano = new Actor("Michael", "Angarano"); - Actor reeceThompson = new Actor("Reece", "Thompson"); - - Film killBill = new Film( - Title.of("Kill Bill"), - english, - 111, - Year.of(2015) - ); - Film meerjungfrauen = new Film( - Title.of("Meerjungfrauen ticken anders"), - german, - 89, - Year.of(2017) - ); - - killBill.actors.addAll(Arrays.asList(umaThurman, davidCarradine, darylHannah)); - meerjungfrauen.actors.addAll(Arrays.asList(umaThurman, michaelAngarano, reeceThompson)); - - em.persist(english); - em.persist(german); - - em.persist(umaThurman); - em.persist(davidCarradine); - em.persist(darylHannah); - em.persist(michaelAngarano); - em.persist(reeceThompson); - - em.persist(killBill); - em.persist(meerjungfrauen); - - // Flush your changes to the database to be sure that jOOQ can pick them up below - // ------------------------------------------------------------------------------ - em.flush(); - System.out.println( ctx.select( ACTOR.FIRSTNAME, @@ -149,107 +77,7 @@ class JPAExample { ); } - // Just ignore that enterprisish bootstrapping madness down there. The beef of the example is above this line - // ---------------------------------------------------------------------------------------------------------- - - @SuppressWarnings("serial") public static void main(String[] args) throws Exception { - Connection connection = null; - EntityManagerFactory emf = null; - EntityManager em = null; - - try { - - // Bootstrapping JDBC: - Class.forName("org.h2.Driver"); - connection = DriverManager.getConnection("jdbc:h2:mem:jooq-jpa-example", "sa", ""); - final Connection c = connection; - - // Creating an in-memory H2 database from our entities - MetadataSources metadata = new MetadataSources( - new StandardServiceRegistryBuilder() - .applySetting("hibernate.dialect", "org.hibernate.dialect.H2Dialect") - .applySetting("javax.persistence.schema-generation-connection", connection) - .applySetting("javax.persistence.create-database-schemas", true) - - // [#5607] JPADatabase causes warnings - This prevents - // them - .applySetting(AvailableSettings.CONNECTION_PROVIDER, new ConnectionProvider() { - @SuppressWarnings("rawtypes") - @Override - public boolean isUnwrappableAs(Class unwrapType) { - return false; - } - - @Override - public T unwrap(Class unwrapType) { - return null; - } - - @Override - public Connection getConnection() { - return c; - } - - @Override - public void closeConnection(Connection conn) throws SQLException {} - - @Override - public boolean supportsAggressiveRelease() { - return true; - } - }) - .build()); - - metadata.addAnnotatedClass(Actor.class); - metadata.addAnnotatedClass(Film.class); - metadata.addAnnotatedClass(Language.class); - - SchemaExport export = new SchemaExport(); - export.create(EnumSet.of(TargetType.DATABASE), metadata.buildMetadata()); - - // Setting up an EntityManager using Spring (much easier than out-of-the-box Hibernate) - LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean(); - HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter(); - adapter.setDatabasePlatform(SQLDialect.H2.thirdParty().hibernateDialect()); - bean.setDataSource(new SingleConnectionDataSource(connection, true)); - bean.setPackagesToScan("org.jooq.example.jpa.entity"); - bean.setJpaVendorAdapter(adapter); - bean.setPersistenceUnitName("test"); - bean.setPersistenceProviderClass(HibernatePersistenceProvider.class); - bean.afterPropertiesSet(); - - emf = bean.getObject(); - em = emf.createEntityManager(); - - final EntityManager e = em; - - // Run some Hibernate / jOOQ logic inside of a transaction - em.getTransaction().begin(); - run( - em, - DSL.using(new DefaultConfiguration() - .set(connection) - .set(new DefaultExecuteListener() { - @Override - public void start(ExecuteContext ctx) { - // Flush all changes from the EntityManager to the database for them to be visible in jOOQ - e.flush(); - super.start(ctx); - } - }) - )); - em.getTransaction().commit(); - } - finally { - if (em != null) - em.close(); - - if (emf != null) - emf.close(); - - if (connection != null) - connection.close(); - } + Setup.run(JPAExample::run); } } diff --git a/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/Setup.java b/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/Setup.java new file mode 100644 index 0000000000..378da98ce1 --- /dev/null +++ b/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/Setup.java @@ -0,0 +1,228 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Other licenses: + * ----------------------------------------------------------------------------- + * Commercial licenses for this work are available. These replace the above + * ASL 2.0 and offer limited warranties, support, maintenance, and commercial + * database integrations. + * + * For more information, please visit: http://www.jooq.org/licenses + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + */ +package org.jooq.example.jpa; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.time.Year; +import java.util.Arrays; +import java.util.EnumSet; +import java.util.function.BiConsumer; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; + +import org.jooq.DSLContext; +import org.jooq.ExecuteContext; +import org.jooq.SQLDialect; +import org.jooq.example.jpa.embeddables.Title; +import org.jooq.example.jpa.entity.Actor; +import org.jooq.example.jpa.entity.Film; +import org.jooq.example.jpa.entity.Language; +import org.jooq.impl.DSL; +import org.jooq.impl.DefaultConfiguration; +import org.jooq.impl.DefaultExecuteListener; +import org.jooq.tools.jdbc.LoggingConnection; + +import org.hibernate.boot.MetadataSources; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.cfg.AvailableSettings; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.jpa.HibernatePersistenceProvider; +import org.hibernate.tool.hbm2ddl.SchemaExport; +import org.hibernate.tool.schema.TargetType; +import org.springframework.jdbc.datasource.SingleConnectionDataSource; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; + +/** + * @author Lukas Eder + */ +final class Setup { + + // This class sets up an EntityManager and configures the jOOQ DSLContext + // ---------------------------------------------------------------------- + + static void run(BiConsumer consumer) throws Exception { + Connection connection = null; + EntityManagerFactory emf = null; + EntityManager em = null; + + try { + + // Bootstrapping JDBC: + Class.forName("org.h2.Driver"); + connection = new LoggingConnection(DriverManager.getConnection("jdbc:h2:mem:jooq-jpa-example", "sa", "")); + final Connection c = connection; + + // Creating an in-memory H2 database from our entities + MetadataSources metadata = new MetadataSources( + new StandardServiceRegistryBuilder() + .applySetting("hibernate.dialect", "org.hibernate.dialect.H2Dialect") + .applySetting("javax.persistence.schema-generation-connection", connection) + .applySetting("javax.persistence.create-database-schemas", true) + + // [#5607] JPADatabase causes warnings - This prevents + // them + .applySetting(AvailableSettings.CONNECTION_PROVIDER, new ConnectionProvider() { + @SuppressWarnings("rawtypes") + @Override + public boolean isUnwrappableAs(Class unwrapType) { + return false; + } + + @Override + public T unwrap(Class unwrapType) { + return null; + } + + @Override + public Connection getConnection() { + return c; + } + + @Override + public void closeConnection(Connection conn) throws SQLException {} + + @Override + public boolean supportsAggressiveRelease() { + return true; + } + }) + .build()); + + metadata.addAnnotatedClass(Actor.class); + metadata.addAnnotatedClass(Film.class); + metadata.addAnnotatedClass(Language.class); + + SchemaExport export = new SchemaExport(); + export.create(EnumSet.of(TargetType.DATABASE), metadata.buildMetadata()); + + // Setting up an EntityManager using Spring (much easier than out-of-the-box Hibernate) + LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean(); + HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter(); + adapter.setDatabasePlatform(SQLDialect.H2.thirdParty().hibernateDialect()); + bean.setDataSource(new SingleConnectionDataSource(connection, true)); + bean.setPackagesToScan("org.jooq.example.jpa.entity"); + bean.setJpaVendorAdapter(adapter); + bean.setPersistenceUnitName("test"); + bean.setPersistenceProviderClass(HibernatePersistenceProvider.class); + bean.afterPropertiesSet(); + + emf = bean.getObject(); + em = emf.createEntityManager(); + + final EntityManager e = em; + + // Run some Hibernate / jOOQ logic inside of a transaction + em.getTransaction().begin(); + data(em); + + consumer.accept( + em, + DSL.using(new DefaultConfiguration() + .set(connection) + .set(new DefaultExecuteListener() { + @Override + public void start(ExecuteContext ctx) { + // Flush all changes from the EntityManager to the database for them to be visible in jOOQ + e.flush(); + super.start(ctx); + } + }) + )); + em.getTransaction().commit(); + } + finally { + if (em != null) + em.close(); + + if (emf != null) + emf.close(); + + if (connection != null) + connection.close(); + } + } + + static void data(EntityManager em) { + + // Set up database + // --------------- + Language english = new Language("English"); + Language german = new Language("German"); + + Actor umaThurman = new Actor("Uma", "Thurman"); + Actor davidCarradine = new Actor("David", "Carradine"); + Actor darylHannah = new Actor("Daryl", "Hannah"); + Actor michaelAngarano = new Actor("Michael", "Angarano"); + Actor reeceThompson = new Actor("Reece", "Thompson"); + + Film killBill = new Film( + Title.of("Kill Bill"), + english, + 111, + Year.of(2015) + ); + Film meerjungfrauen = new Film( + Title.of("Meerjungfrauen ticken anders"), + german, + 89, + Year.of(2017) + ); + + killBill.actors.addAll(Arrays.asList(umaThurman, davidCarradine, darylHannah)); + meerjungfrauen.actors.addAll(Arrays.asList(umaThurman, michaelAngarano, reeceThompson)); + + em.persist(english); + em.persist(german); + + em.persist(umaThurman); + em.persist(davidCarradine); + em.persist(darylHannah); + em.persist(michaelAngarano); + em.persist(reeceThompson); + + em.persist(killBill); + em.persist(meerjungfrauen); + em.flush(); + } + + private Setup() {} +} diff --git a/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/jooq/tables/Actor.java b/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/jooq/tables/Actor.java index 6a6d35db5e..0524ba0de6 100644 --- a/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/jooq/tables/Actor.java +++ b/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/jooq/tables/Actor.java @@ -31,7 +31,7 @@ import org.jooq.impl.TableImpl; @SuppressWarnings({ "all", "unchecked", "rawtypes" }) public class Actor extends TableImpl { - private static final long serialVersionUID = -102517780; + private static final long serialVersionUID = -197980969; /** * The reference instance of PUBLIC.ACTOR @@ -49,17 +49,17 @@ public class Actor extends TableImpl { /** * The column PUBLIC.ACTOR.ACTORID. */ - public final TableField ACTORID = createField("ACTORID", org.jooq.impl.SQLDataType.INTEGER.nullable(false).identity(true), this, ""); + public final TableField ACTORID = createField(DSL.name("ACTORID"), org.jooq.impl.SQLDataType.INTEGER.nullable(false).identity(true), this, ""); /** * The column PUBLIC.ACTOR.FIRSTNAME. */ - public final TableField FIRSTNAME = createField("FIRSTNAME", org.jooq.impl.SQLDataType.VARCHAR(255), this, ""); + public final TableField FIRSTNAME = createField(DSL.name("FIRSTNAME"), org.jooq.impl.SQLDataType.VARCHAR(255), this, ""); /** * The column PUBLIC.ACTOR.LASTNAME. */ - public final TableField LASTNAME = createField("LASTNAME", org.jooq.impl.SQLDataType.VARCHAR(255), this, ""); + public final TableField LASTNAME = createField(DSL.name("LASTNAME"), org.jooq.impl.SQLDataType.VARCHAR(255), this, ""); /** * Create a PUBLIC.ACTOR table reference diff --git a/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/jooq/tables/Film.java b/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/jooq/tables/Film.java index 23380c0b18..0f9e295555 100644 --- a/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/jooq/tables/Film.java +++ b/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/jooq/tables/Film.java @@ -4,7 +4,6 @@ package org.jooq.example.jpa.jooq.tables; -import java.time.Year; import java.util.Arrays; import java.util.List; @@ -32,7 +31,7 @@ import org.jooq.impl.TableImpl; @SuppressWarnings({ "all", "unchecked", "rawtypes" }) public class Film extends TableImpl { - private static final long serialVersionUID = 1433747065; + private static final long serialVersionUID = 1425273525; /** * The reference instance of PUBLIC.FILM @@ -50,32 +49,33 @@ public class Film extends TableImpl { /** * The column PUBLIC.FILM.FILMID. */ - public final TableField FILMID = createField("FILMID", org.jooq.impl.SQLDataType.INTEGER.nullable(false).identity(true), this, ""); + public final TableField FILMID = createField(DSL.name("FILMID"), org.jooq.impl.SQLDataType.INTEGER.nullable(false).identity(true), this, ""); /** * The column PUBLIC.FILM.LENGTH. */ - public final TableField LENGTH = createField("LENGTH", org.jooq.impl.SQLDataType.INTEGER, this, ""); + public final TableField LENGTH = createField(DSL.name("LENGTH"), org.jooq.impl.SQLDataType.INTEGER, this, ""); /** - * The column PUBLIC.FILM.RELEASE_YEAR. + * @deprecated Unknown data type. Please define an explicit {@link org.jooq.Binding} to specify how this type should be handled. Deprecation can be turned off using {@literal } in your code generator configuration. */ - public final TableField RELEASE_YEAR = createField("RELEASE_YEAR", org.jooq.impl.SQLDataType.INTEGER, this, "", new org.jooq.impl.JPAConverter(org.jooq.example.jpa.converters.YearConverter.class)); + @java.lang.Deprecated + public final TableField RELEASE_YEAR = createField(DSL.name("RELEASE_YEAR"), org.jooq.impl.SQLDataType.INTEGER, this, "", new org.jooq.impl.JPAConverter(org.jooq.example.jpa.converters.YearConverter.class)); /** * The column PUBLIC.FILM.TITLE. */ - public final TableField TITLE = createField("TITLE", org.jooq.impl.SQLDataType.VARCHAR(255), this, ""); + public final TableField TITLE = createField(DSL.name("TITLE"), org.jooq.impl.SQLDataType.VARCHAR(255), this, ""); /** * The column PUBLIC.FILM.LANGUAGE_LANGUAGEID. */ - public final TableField LANGUAGE_LANGUAGEID = createField("LANGUAGE_LANGUAGEID", org.jooq.impl.SQLDataType.INTEGER, this, ""); + public final TableField LANGUAGE_LANGUAGEID = createField(DSL.name("LANGUAGE_LANGUAGEID"), org.jooq.impl.SQLDataType.INTEGER, this, ""); /** * The column PUBLIC.FILM.ORIGINALLANGUAGE_LANGUAGEID. */ - public final TableField ORIGINALLANGUAGE_LANGUAGEID = createField("ORIGINALLANGUAGE_LANGUAGEID", org.jooq.impl.SQLDataType.INTEGER, this, ""); + public final TableField ORIGINALLANGUAGE_LANGUAGEID = createField(DSL.name("ORIGINALLANGUAGE_LANGUAGEID"), org.jooq.impl.SQLDataType.INTEGER, this, ""); /** * Create a PUBLIC.FILM table reference diff --git a/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/jooq/tables/FilmActor.java b/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/jooq/tables/FilmActor.java index 2af597b381..5d68e0b7ac 100644 --- a/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/jooq/tables/FilmActor.java +++ b/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/jooq/tables/FilmActor.java @@ -30,7 +30,7 @@ import org.jooq.impl.TableImpl; @SuppressWarnings({ "all", "unchecked", "rawtypes" }) public class FilmActor extends TableImpl { - private static final long serialVersionUID = -2005425571; + private static final long serialVersionUID = 1565489533; /** * The reference instance of PUBLIC.FILM_ACTOR @@ -48,12 +48,12 @@ public class FilmActor extends TableImpl { /** * The column PUBLIC.FILM_ACTOR.FILMS_FILMID. */ - public final TableField FILMS_FILMID = createField("FILMS_FILMID", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + public final TableField FILMS_FILMID = createField(DSL.name("FILMS_FILMID"), org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); /** * The column PUBLIC.FILM_ACTOR.ACTORS_ACTORID. */ - public final TableField ACTORS_ACTORID = createField("ACTORS_ACTORID", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); + public final TableField ACTORS_ACTORID = createField(DSL.name("ACTORS_ACTORID"), org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); /** * Create a PUBLIC.FILM_ACTOR table reference diff --git a/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/jooq/tables/Language.java b/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/jooq/tables/Language.java index d738c0e688..d35bd45f9a 100644 --- a/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/jooq/tables/Language.java +++ b/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/jooq/tables/Language.java @@ -31,7 +31,7 @@ import org.jooq.impl.TableImpl; @SuppressWarnings({ "all", "unchecked", "rawtypes" }) public class Language extends TableImpl { - private static final long serialVersionUID = 1261703936; + private static final long serialVersionUID = -636203274; /** * The reference instance of PUBLIC.LANGUAGE @@ -49,12 +49,12 @@ public class Language extends TableImpl { /** * The column PUBLIC.LANGUAGE.LANGUAGEID. */ - public final TableField LANGUAGEID = createField("LANGUAGEID", org.jooq.impl.SQLDataType.INTEGER.nullable(false).identity(true), this, ""); + public final TableField LANGUAGEID = createField(DSL.name("LANGUAGEID"), org.jooq.impl.SQLDataType.INTEGER.nullable(false).identity(true), this, ""); /** * The column PUBLIC.LANGUAGE.NAME. */ - public final TableField NAME = createField("NAME", org.jooq.impl.SQLDataType.VARCHAR(255), this, ""); + public final TableField NAME = createField(DSL.name("NAME"), org.jooq.impl.SQLDataType.VARCHAR(255), this, ""); /** * Create a PUBLIC.LANGUAGE table reference diff --git a/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/jooq/tables/records/FilmRecord.java b/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/jooq/tables/records/FilmRecord.java index 1fb6f312d4..a10aae1c17 100644 --- a/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/jooq/tables/records/FilmRecord.java +++ b/jOOQ-examples/jOOQ-jpa-example/src/main/java/org/jooq/example/jpa/jooq/tables/records/FilmRecord.java @@ -4,8 +4,6 @@ package org.jooq.example.jpa.jooq.tables.records; -import java.time.Year; - import org.jooq.Field; import org.jooq.Record1; import org.jooq.Record6; @@ -18,9 +16,9 @@ import org.jooq.impl.UpdatableRecordImpl; * This class is generated by jOOQ. */ @SuppressWarnings({ "all", "unchecked", "rawtypes" }) -public class FilmRecord extends UpdatableRecordImpl implements Record6 { +public class FilmRecord extends UpdatableRecordImpl implements Record6 { - private static final long serialVersionUID = 2076456687; + private static final long serialVersionUID = -596044573; /** * Setter for PUBLIC.FILM.FILMID. @@ -51,17 +49,19 @@ public class FilmRecord extends UpdatableRecordImpl implements Recor } /** - * Setter for PUBLIC.FILM.RELEASE_YEAR. + * @deprecated Unknown data type. Please define an explicit {@link org.jooq.Binding} to specify how this type should be handled. Deprecation can be turned off using {@literal } in your code generator configuration. */ - public void setReleaseYear(Year value) { + @java.lang.Deprecated + public void setReleaseYear(Object value) { set(2, value); } /** - * Getter for PUBLIC.FILM.RELEASE_YEAR. + * @deprecated Unknown data type. Please define an explicit {@link org.jooq.Binding} to specify how this type should be handled. Deprecation can be turned off using {@literal } in your code generator configuration. */ - public Year getReleaseYear() { - return (Year) get(2); + @java.lang.Deprecated + public Object getReleaseYear() { + return get(2); } /** @@ -126,7 +126,7 @@ public class FilmRecord extends UpdatableRecordImpl implements Recor * {@inheritDoc} */ @Override - public Row6 fieldsRow() { + public Row6 fieldsRow() { return (Row6) super.fieldsRow(); } @@ -134,7 +134,7 @@ public class FilmRecord extends UpdatableRecordImpl implements Recor * {@inheritDoc} */ @Override - public Row6 valuesRow() { + public Row6 valuesRow() { return (Row6) super.valuesRow(); } @@ -155,10 +155,11 @@ public class FilmRecord extends UpdatableRecordImpl implements Recor } /** - * {@inheritDoc} + * @deprecated Unknown data type. Please define an explicit {@link org.jooq.Binding} to specify how this type should be handled. Deprecation can be turned off using {@literal } in your code generator configuration. */ + @java.lang.Deprecated @Override - public Field field3() { + public Field field3() { return Film.FILM.RELEASE_YEAR; } @@ -203,10 +204,11 @@ public class FilmRecord extends UpdatableRecordImpl implements Recor } /** - * {@inheritDoc} + * @deprecated Unknown data type. Please define an explicit {@link org.jooq.Binding} to specify how this type should be handled. Deprecation can be turned off using {@literal } in your code generator configuration. */ + @java.lang.Deprecated @Override - public Year component3() { + public Object component3() { return getReleaseYear(); } @@ -251,10 +253,11 @@ public class FilmRecord extends UpdatableRecordImpl implements Recor } /** - * {@inheritDoc} + * @deprecated Unknown data type. Please define an explicit {@link org.jooq.Binding} to specify how this type should be handled. Deprecation can be turned off using {@literal } in your code generator configuration. */ + @java.lang.Deprecated @Override - public Year value3() { + public Object value3() { return getReleaseYear(); } @@ -301,10 +304,11 @@ public class FilmRecord extends UpdatableRecordImpl implements Recor } /** - * {@inheritDoc} + * @deprecated Unknown data type. Please define an explicit {@link org.jooq.Binding} to specify how this type should be handled. Deprecation can be turned off using {@literal } in your code generator configuration. */ + @java.lang.Deprecated @Override - public FilmRecord value3(Year value) { + public FilmRecord value3(Object value) { setReleaseYear(value); return this; } @@ -340,7 +344,7 @@ public class FilmRecord extends UpdatableRecordImpl implements Recor * {@inheritDoc} */ @Override - public FilmRecord values(Integer value1, Integer value2, Year value3, String value4, Integer value5, Integer value6) { + public FilmRecord values(Integer value1, Integer value2, Object value3, String value4, Integer value5, Integer value6) { value1(value1); value2(value2); value3(value3); @@ -364,7 +368,7 @@ public class FilmRecord extends UpdatableRecordImpl implements Recor /** * Create a detached, initialised FilmRecord */ - public FilmRecord(Integer filmid, Integer length, Year releaseYear, String title, Integer languageLanguageid, Integer originallanguageLanguageid) { + public FilmRecord(Integer filmid, Integer length, Object releaseYear, String title, Integer languageLanguageid, Integer originallanguageLanguageid) { super(Film.FILM); set(0, filmid);