{"id":20847,"date":"2014-02-03T10:00:22","date_gmt":"2014-02-03T08:00:22","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=20847"},"modified":"2014-02-03T07:51:12","modified_gmt":"2014-02-03T05:51:12","slug":"using-jooq-with-spring-code-generation","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2014\/02\/using-jooq-with-spring-code-generation.html","title":{"rendered":"Using jOOQ with Spring: Code Generation"},"content":{"rendered":"<p>As we might remember from the <a href=\"\/programming\/jooq\/using-jooq-with-spring-configuration\/\">first part of this tutorial<\/a>, jOOQ states that<\/p>\n<blockquote>\n<p>jOOQ generates Java code from your database and lets you build typesafe SQL queries through its fluent API.<\/p>\n<\/blockquote>\n<p>The first part of this tutorial describes how we can <a href=\"\/programming\/jooq\/using-jooq-with-spring-configuration\/\">configure the application context of a Spring powered application which uses jOOQ<\/a> but it doesn\u2019t describe how we can create typesafe SQL queries with jOOQ.<\/p>\n<p>This blog post takes us one step closer to the solution. If we want to build typesafe database queries with jOOQ, we have to reverse-engineer our database and create classes which represents different database tables, records, and so on. These classes are the building blocks of typesafe SQL queries.<\/p>\n<p>Luckily jOOQ provides <a href=\"http:\/\/www.jooq.org\/doc\/3.2\/manual-single-page\/#code-generation\" target=\"_blank\">an easy way to automate this process<\/a>. This blog post describes how we can generate the required classes with Maven.<\/p>\n<p>Let\u2019s get started.<\/p>\n<blockquote>\n<h3>Additional reading:<\/h3>\n<ul>\n<li><a href=\"\/programming\/tips-and-tricks\/creating-profile-specific-configuration-files-with-maven\/\">Creating Profile Specific Configuration Files with Maven<\/a> explains how you can create different configurations for different environment by using Maven build profiles. The example application of this blog post is configured by using the approach described in this blog post.<\/li>\n<li><a href=\"\/programming\/jooq\/using-jooq-with-spring-configuration\/\">Using jOOQ with Spring: Configuration<\/a> is the first part of this tutorial and it describes you can configure the application context of a Spring application which uses jOOQ. You understand this blog post without reading the first part of this tutorial, but if you want to really use jOOQ in a Spring powered application, I recommend that you read that blog post as well.<\/li>\n<\/ul>\n<\/blockquote>\n<h3>Generating Code with Maven<\/h3>\n<p>Our build process is divided into three important phases which are described in the following:<\/p>\n<ol>\n<li><strong>Read the database configuration from the profile specific configuration file<\/strong>. We want to use the same configuration file for our application and our build script because this helps us to avoid duplication. We need the database connection details when we update our database schema and generate code from our database.<\/li>\n<li><strong>Update the database schema if needed<\/strong>. Because we want to generate code from our database, we have to ensure that its schema is updated before the code generation is started.<\/li>\n<li><strong>Generate code from the database<\/strong>. This phase reads the metadata from the configured database and creates the classes which are used to write typesafe database queries with jOOQ.<\/li>\n<\/ol>\n<p>Let\u2019s move on and find out how we can configure these phases in our <em>pom.xml<\/em> file.<\/p>\n<h3>Reading the Properties From the Profile Specific Properties File<\/h3>\n<p>We can read the properties from the profile specific properties file by using the <a href=\"http:\/\/mojo.codehaus.org\/properties-maven-plugin\/\" target=\"_blank\">Properties Maven plugin<\/a>. This plugin reads the contents of a properties file and ensures that we can use its properties in our <em>pom.xml<\/em> file.<\/p>\n<p>We can configure this plugin by following these steps:<\/p>\n<ol>\n<li>Add the plugin declaration to the <em>plugins<\/em> section of the <em>pom.xml<\/em> file.<\/li>\n<li>Create an execution which runs the <em>read-project-properties<\/em> goal in the <em>initialize<\/em> Maven lifecycle phase.<\/li>\n<li>Ensure that the properties are read from the profile specific configuration file (<em>profiles\/${build.profile.id}\/config.properties<\/em>).<\/li>\n<\/ol>\n<p>The configuration of the Properties Maven plugin looks as follows:<\/p>\n<pre class=\"brush:xml\">&lt;plugin&gt;\r\n    &lt;groupId&gt;org.codehaus.mojo&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;properties-maven-plugin&lt;\/artifactId&gt;\r\n    &lt;version&gt;1.0-alpha-2&lt;\/version&gt;\r\n    &lt;executions&gt;\r\n        &lt;execution&gt;\r\n            &lt;phase&gt;initialize&lt;\/phase&gt;\r\n            &lt;goals&gt;\r\n                &lt;goal&gt;read-project-properties&lt;\/goal&gt;\r\n            &lt;\/goals&gt;\r\n            &lt;configuration&gt;\r\n                &lt;files&gt;\r\n                    &lt;file&gt;profiles\/${build.profile.id}\/config.properties&lt;\/file&gt;\r\n                &lt;\/files&gt;\r\n            &lt;\/configuration&gt;\r\n        &lt;\/execution&gt;\r\n    &lt;\/executions&gt;\r\n&lt;\/plugin&gt;<\/pre>\n<p>Let\u2019s move on and find out how we can update the database schema of our application.<\/p>\n<h3>Updating the Database Schema<\/h3>\n<p>Before we can generate any code from a database, we have to ensure that the schema of our database is up-to-date. The easiest way to do this is to use the <a href=\"http:\/\/mojo.codehaus.org\/sql-maven-plugin\/\" target=\"_blank\">SQL Maven plugin<\/a> which can execute SQL statements found from a SQL file.<\/p>\n<blockquote>\n<p>In a real life application you probably want to use either <a href=\"http:\/\/flywaydb.org\/\" target=\"_blank\">Flyway<\/a> or <a href=\"http:\/\/www.liquibase.org\/\" target=\"_blank\">Liquibase<\/a> for this purpose.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<\/blockquote>\n<p>Let\u2019s find out how we can ensure that the database of our example is always up-to-date.<\/p>\n<p><b>First<\/b>, we have to create the SQL file which creates the database schema. This SQL script will create the <em>todos<\/em> table if it isn\u2019t found from the database.<\/p>\n<p>The <em>schema.sql<\/em> file looks as follows:<\/p>\n<pre class=\"brush:sql\">CREATE TABLE IF NOT EXISTS todos (\r\n  id BIGINT AUTO_INCREMENT PRIMARY KEY,\r\n  creation_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\r\n  description VARCHAR(500),\r\n  modification_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\r\n  title VARCHAR(100)\r\n);<\/pre>\n<p><b>Second<\/b>, we have to add a <em>skip.db.creation<\/em> property to the <em>properties<\/em> section of the <em>pom.xml<\/em> file. This property is used to enable and disable the schema update. Because we want to enable the database schema update in all profiles, we have to set the value of this property to <em>false<\/em>.<\/p>\n<p>The relevant part of our POM file looks as follows:<\/p>\n<pre class=\"brush:xml\">&lt;properties&gt;\r\n    &lt;skip.db.creation&gt;false&lt;\/skip.db.creation&gt;\r\n&lt;\/properties&gt;<\/pre>\n<p><b>Third<\/b>, we have to configure the SQL Maven plugin. We can do this by following these steps:<\/p>\n<ol>\n<li>Add the plugin declaration to the <em>plugins<\/em> section of the <em>pom.xml<\/em> file.<\/li>\n<li>Ensure that the schema generation is skipped if the value of <em>skip.db.creation<\/em> property is <em>true<\/em>.<\/li>\n<li>Create an execution which runs the <em>execute<\/em> goal in the <em>generate-sources<\/em> Maven lifecycle phase.<\/li>\n<li>Configure the created execution by following these steps:\n<ol>\n<li>Configure the JDBC driver, database url, username, and password.<\/li>\n<li>Ensure that the changes are committed automatically.<\/li>\n<li>Configure the location of the SQL script which creates the schema of our database.<\/li>\n<\/ol>\n<\/li>\n<li>Add the H2 database as the dependency of this plugin.<\/li>\n<\/ol>\n<p>The configuration of the SQL Maven plugin looks as follows:<\/p>\n<pre class=\"brush:xml\">&lt;plugin&gt;\r\n&lt;groupId&gt;org.codehaus.mojo&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;sql-maven-plugin&lt;\/artifactId&gt;\r\n    &lt;version&gt;1.5&lt;\/version&gt;\r\n\r\n    &lt;configuration&gt;\r\n        &lt;skip&gt;${skip.db.creation}&lt;\/skip&gt;\r\n    &lt;\/configuration&gt;\r\n\r\n    &lt;executions&gt;\r\n        &lt;execution&gt;\r\n            &lt;id&gt;create-database-h2&lt;\/id&gt;\r\n            &lt;phase&gt;generate-sources&lt;\/phase&gt;\r\n            &lt;goals&gt;\r\n                &lt;goal&gt;execute&lt;\/goal&gt;\r\n            &lt;\/goals&gt;\r\n            &lt;configuration&gt;\r\n                &lt;driver&gt;${db.driver}&lt;\/driver&gt;\r\n                &lt;url&gt;${db.url}&lt;\/url&gt;\r\n                &lt;username&gt;${db.username}&lt;\/username&gt;\r\n                &lt;password&gt;${db.password}&lt;\/password&gt;\r\n\r\n                &lt;autocommit&gt;true&lt;\/autocommit&gt;\r\n                &lt;srcFiles&gt;\r\n                    &lt;srcFile&gt;src\/main\/resources\/schema.sql&lt;\/srcFile&gt;\r\n                &lt;\/srcFiles&gt;\r\n            &lt;\/configuration&gt;\r\n        &lt;\/execution&gt;\r\n    &lt;\/executions&gt;\r\n\r\n    &lt;dependencies&gt;\r\n        &lt;dependency&gt;\r\n            &lt;groupId&gt;com.h2database&lt;\/groupId&gt;\r\n            &lt;artifactId&gt;h2&lt;\/artifactId&gt;\r\n            &lt;version&gt;1.3.174&lt;\/version&gt;\r\n        &lt;\/dependency&gt;\r\n    &lt;\/dependencies&gt;\r\n&lt;\/plugin&gt;<\/pre>\n<p>Let\u2019s move on and find out how we can configured the jOOQ-codegen Maven plugin.<\/p>\n<h3>Generating Code from the Database<\/h3>\n<p>Our last task is to configure the jOOQ-codegen Maven plugin. Let\u2019s find out how this is done.<\/p>\n<p><strong>First<\/strong>, We have to add a <em>jooq.generator.db.dialect<\/em> property to the <em>properties<\/em> section section of the <em>pom.xml<\/em> file. This property specifies the correct database dialect and it is used to configure the jOOQ-codegen Maven plugin. Because our example application uses the H2 database, we have to set the value of this property to <em>org.jooq.util.h2.H2Database<\/em>.<\/p>\n<p>The reason why the database dialect is specified as a property is that this gives us the possibility to use different databases in different environments.<\/p>\n<p>The relevant part of our POM file looks as follows:<\/p>\n<pre class=\"brush:xml\">&lt;properties&gt;\r\n    &lt;jooq.generator.db.dialect&gt;org.jooq.util.h2.H2Database&lt;\/jooq.generator.db.dialect&gt;\r\n&lt;\/properties&gt;<\/pre>\n<p><strong>Second<\/strong>, we have to configure the jOOQ-codegen Maven plugin. We can do this by following these steps:<\/p>\n<ol>\n<li>Add the plugin declaration to the <em>plugins<\/em> section of the <em>pom.xml<\/em> file.<\/li>\n<li>Create an execution which runs the <em>generate<\/em> goal of the jOOQ-codegen Maven plugin during the <em>generate-sources<\/em> Maven lifecycle phase.<\/li>\n<li>Configure the plugin by following these steps:\n<ol>\n<li>Configure the JDBC connection and set the name of the driver class, database url, username, and password. Remember that the actual property values are read from the profile specific configuration file.<\/li>\n<li>Configure the database which is used as the source by following these steps:\n<ol>\n<li>Ensure that the used database dialect is read from the <em>jooq.generator.db.dialect<\/em> property.<\/li>\n<li>Configure the code generation to include all tables found from the <em>PUBLIC<\/em> schema.<\/li>\n<\/ol>\n<\/li>\n<li>Configure the code generation to generate classes for database <a href=\"http:\/\/www.jooq.org\/doc\/3.2\/manual-single-page\/#codegen-tables\" target=\"_blank\">tables<\/a> and <a href=\"http:\/\/www.jooq.org\/doc\/3.2\/manual-single-page\/#codegen-records\" target=\"_blank\">records<\/a>.<\/li>\n<li>Configure the target package and directory. These configuration options are described in the following:\n<ul>\n<li>The target package specifies the package which is the root package of the created classes.<\/li>\n<li>The target directory specifies the directory in which the classes are generated.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<\/li>\n<li>Add the H2 database as the dependency of this plugin.<\/li>\n<\/ol>\n<p>The configuration of the jOOQ-codegen Maven plugin looks as follows:<\/p>\n<pre class=\"brush:xml\">&lt;plugin&gt;\r\n    &lt;groupId&gt;org.jooq&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;jooq-codegen-maven&lt;\/artifactId&gt;\r\n    &lt;version&gt;3.2.2&lt;\/version&gt;\r\n\r\n    &lt;executions&gt;\r\n        &lt;execution&gt;\r\n            &lt;id&gt;generate-h2&lt;\/id&gt;\r\n            &lt;phase&gt;generate-sources&lt;\/phase&gt;\r\n            &lt;goals&gt;\r\n                &lt;goal&gt;generate&lt;\/goal&gt;\r\n            &lt;\/goals&gt;\r\n        &lt;\/execution&gt;\r\n    &lt;\/executions&gt;\r\n\r\n    &lt;dependencies&gt;\r\n        &lt;dependency&gt;\r\n            &lt;groupId&gt;com.h2database&lt;\/groupId&gt;\r\n            &lt;artifactId&gt;h2&lt;\/artifactId&gt;\r\n            &lt;version&gt;${h2.version}&lt;\/version&gt;\r\n        &lt;\/dependency&gt;\r\n    &lt;\/dependencies&gt;\r\n\r\n    &lt;configuration&gt;\r\n        &lt;jdbc&gt;\r\n            &lt;driver&gt;${db.driver}&lt;\/driver&gt;\r\n            &lt;url&gt;${db.url}&lt;\/url&gt;\r\n            &lt;user&gt;${db.username}&lt;\/user&gt;\r\n            &lt;password&gt;${db.password}&lt;\/password&gt;\r\n        &lt;\/jdbc&gt;\r\n\r\n        &lt;generator&gt;\r\n            &lt;database&gt;\r\n                &lt;name&gt;${jooq.generator.db.dialect}&lt;\/name&gt;\r\n                &lt;includes&gt;.*&lt;\/includes&gt;\r\n                &lt;excludes&gt;&lt;\/excludes&gt;\r\n                &lt;inputSchema&gt;PUBLIC&lt;\/inputSchema&gt;\r\n            &lt;\/database&gt;\r\n            &lt;generate&gt;\r\n                &lt;records&gt;true&lt;\/records&gt;\r\n            &lt;\/generate&gt;\r\n            &lt;target&gt;\r\n                &lt;packageName&gt;net.petrikainulainen.spring.jooq.todo.db&lt;\/packageName&gt;\r\n                &lt;directory&gt;target\/generated-sources\/jooq&lt;\/directory&gt;\r\n            &lt;\/target&gt;\r\n        &lt;\/generator&gt;\r\n    &lt;\/configuration&gt;\r\n&lt;\/plugin&gt;\r\n<\/pre>\n<blockquote>\n<p>You can get more information about the code generation from the jOOQ reference manual:<\/p>\n<ul>\n<li><a href=\"http:\/\/www.jooq.org\/doc\/3.2\/manual-single-page\/#code-generation\" target=\"_blank\">Chapter 6: Code Generation<\/a><\/li>\n<li><a href=\"http:\/\/www.jooq.org\/doc\/3.2\/manual-single-page\/#codegen-advanced\" target=\"_blank\">Section 6.2: Advanced generator configuration<\/a><\/li>\n<li><a href=\"http:\/\/www.jooq.org\/doc\/3.2\/manual-single-page\/#codegen-generatorstrategy\" target=\"_blank\">Section 6.3: Custom generator strategies<\/a><\/li>\n<li><a href=\"http:\/\/www.jooq.org\/doc\/3.2\/manual-single-page\/#codegen-tables\" target=\"_blank\">Section 6.7: Generated tables<\/a><\/li>\n<li><a href=\"http:\/\/www.jooq.org\/doc\/3.2\/manual-single-page\/#codegen-records\" target=\"_blank\">Section 6.8: Generated records<\/a><\/li>\n<\/ul>\n<\/blockquote>\n<p>Let\u2019s find out what happens when the code generation is run.<\/p>\n<h2>What Is Generated?<\/h2>\n<p>When the <em>generate<\/em> goal of the jOOQ-codegen Maven plugin is invoked, it analyzes the schema of the database and generates classes to the configured target directory and package. In our situation, this means that:<\/p>\n<ul>\n<li>The code is generated to the directory <em>target\/generated-sources\/jooq<\/em>.<\/li>\n<li>The root package of the generated classes is <em>net.petrikainulainen.spring.jooq.todo.db<\/em>.<\/li>\n<\/ul>\n<p>The configuration which we created during this blog post ensures that the following classes are created:<\/p>\n<ul>\n<li>The classes generated to the <em>net.petrikainulainen.spring.jooq.todo.db<\/em> package contain the metadata of the database. jOOQ calls these classes <a href=\"http:\/\/www.jooq.org\/doc\/3.2\/manual-single-page\/#codegen-globals\" target=\"_blank\">\u201cglobal\u201d artifacts<\/a>.<\/li>\n<li>The <em>net.petrikainulainen.spring.jooq.todo.db.tables.Todos<\/em> class is a <a href=\"http:\/\/www.jooq.org\/doc\/3.2\/manual-single-page\/#codegen-tables\" target=\"_blank\">table class<\/a> which describes the structure of the a single database table. We can use this class to write database queries against the data stored to the <em>todos<\/em> database table.<\/li>\n<li>The <em>net.petrikainulainen.spring.jooq.todo.db.tables.recods.TodoRecord<\/em> class is a <a href=\"http:\/\/www.jooq.org\/doc\/3.2\/manual-single-page\/#codegen-records\" target=\"_blank\">record class<\/a> which contains the information of a single table row. The database queries which fetch data from the <em>todos<\/em> database table return <em>TodoRecord<\/em> objects (if we choose to do so).<\/li>\n<\/ul>\n<h2>Summary<\/h2>\n<p>We have now successfully configured the jOOQ-codegen Maven plugin to generate code from our database. This tutorial has taught us two things:<\/p>\n<ul>\n<li>We learned how we can configure the jOOQ-codegen Maven plugin to generate code from a database.<\/li>\n<li>We learned what kind of classes are created when the code generation is started.<\/li>\n<\/ul>\n<p>The next part of this tutorial describes how we can add CRUD functions to a simple web application by using the classes generated by jOOQ.<\/p>\n<ul>\n<li>The example application of this blog post is available <a href=\"https:\/\/github.com\/pkainulainen\/jooq-with-spring-examples\/tree\/master\/configuration\" target=\"_blank\">at Github<\/a>.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<div style=\"border: 1px solid #D8D8D8; background: #FAFAFA; width: 100%; padding-left: 5px;\"><b><\/p>\n<\/blockquote>\n<p> <i>Reference: <\/i><\/b><a href=\"http:\/\/www.petrikainulainen.net\/programming\/jooq\/using-jooq-with-spring-code-generation\/\">Using jOOQ with Spring: Code Generation<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/jcg\">JCG partner<\/a> Petri Kainulainen at the <a href=\"http:\/\/www.petrikainulainen.net\/\">Petri Kainulainen<\/a> blog.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>As we might remember from the first part of this tutorial, jOOQ states that jOOQ generates Java code from your database and lets you build typesafe SQL queries through its fluent API. The first part of this tutorial describes how we can configure the application context of a Spring powered application which uses jOOQ but &hellip;<\/p>\n","protected":false},"author":429,"featured_media":38135,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[256,30],"class_list":["post-20847","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-jooq","tag-spring"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Using jOOQ with Spring: Code Generation<\/title>\n<meta name=\"description\" content=\"As we might remember from the first part of this tutorial, jOOQ states that jOOQ generates Java code from your database and lets you build typesafe SQL\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2014\/02\/using-jooq-with-spring-code-generation.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using jOOQ with Spring: Code Generation\" \/>\n<meta property=\"og:description\" content=\"As we might remember from the first part of this tutorial, jOOQ states that jOOQ generates Java code from your database and lets you build typesafe SQL\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2014\/02\/using-jooq-with-spring-code-generation.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2014-02-03T08:00:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2015\/03\/jooq-2-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Petri Kainulainen\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/petrikainulaine\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Petri Kainulainen\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/02\\\/using-jooq-with-spring-code-generation.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/02\\\/using-jooq-with-spring-code-generation.html\"},\"author\":{\"name\":\"Petri Kainulainen\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/5af4df3fdfeb79e9fa3598d79bff2c9e\"},\"headline\":\"Using jOOQ with Spring: Code Generation\",\"datePublished\":\"2014-02-03T08:00:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/02\\\/using-jooq-with-spring-code-generation.html\"},\"wordCount\":1504,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/02\\\/using-jooq-with-spring-code-generation.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2015\\\/03\\\/jooq-2-logo.jpg\",\"keywords\":[\"jOOQ\",\"Spring\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/02\\\/using-jooq-with-spring-code-generation.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/02\\\/using-jooq-with-spring-code-generation.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/02\\\/using-jooq-with-spring-code-generation.html\",\"name\":\"Using jOOQ with Spring: Code Generation\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/02\\\/using-jooq-with-spring-code-generation.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/02\\\/using-jooq-with-spring-code-generation.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2015\\\/03\\\/jooq-2-logo.jpg\",\"datePublished\":\"2014-02-03T08:00:22+00:00\",\"description\":\"As we might remember from the first part of this tutorial, jOOQ states that jOOQ generates Java code from your database and lets you build typesafe SQL\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/02\\\/using-jooq-with-spring-code-generation.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/02\\\/using-jooq-with-spring-code-generation.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/02\\\/using-jooq-with-spring-code-generation.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2015\\\/03\\\/jooq-2-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2015\\\/03\\\/jooq-2-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/02\\\/using-jooq-with-spring-code-generation.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Using jOOQ with Spring: Code Generation\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/5af4df3fdfeb79e9fa3598d79bff2c9e\",\"name\":\"Petri Kainulainen\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9e57425180f323fa65bc519a64c8273d3fcb7c6bd272e56b37dd15613f403659?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9e57425180f323fa65bc519a64c8273d3fcb7c6bd272e56b37dd15613f403659?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9e57425180f323fa65bc519a64c8273d3fcb7c6bd272e56b37dd15613f403659?s=96&d=mm&r=g\",\"caption\":\"Petri Kainulainen\"},\"description\":\"Petri is passionate about software development and continuous improvement. He is specialized in software development with the Spring Framework and is the author of Spring Data book.\",\"sameAs\":[\"http:\\\/\\\/www.petrikainulainen.net\\\/\",\"http:\\\/\\\/www.linkedin.com\\\/in\\\/petrikainulainen\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/petrikainulaine\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/petri-kainulainen\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using jOOQ with Spring: Code Generation","description":"As we might remember from the first part of this tutorial, jOOQ states that jOOQ generates Java code from your database and lets you build typesafe SQL","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2014\/02\/using-jooq-with-spring-code-generation.html","og_locale":"en_US","og_type":"article","og_title":"Using jOOQ with Spring: Code Generation","og_description":"As we might remember from the first part of this tutorial, jOOQ states that jOOQ generates Java code from your database and lets you build typesafe SQL","og_url":"https:\/\/www.javacodegeeks.com\/2014\/02\/using-jooq-with-spring-code-generation.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2014-02-03T08:00:22+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2015\/03\/jooq-2-logo.jpg","type":"image\/jpeg"}],"author":"Petri Kainulainen","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/petrikainulaine","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Petri Kainulainen","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2014\/02\/using-jooq-with-spring-code-generation.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/02\/using-jooq-with-spring-code-generation.html"},"author":{"name":"Petri Kainulainen","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/5af4df3fdfeb79e9fa3598d79bff2c9e"},"headline":"Using jOOQ with Spring: Code Generation","datePublished":"2014-02-03T08:00:22+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/02\/using-jooq-with-spring-code-generation.html"},"wordCount":1504,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/02\/using-jooq-with-spring-code-generation.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2015\/03\/jooq-2-logo.jpg","keywords":["jOOQ","Spring"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2014\/02\/using-jooq-with-spring-code-generation.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2014\/02\/using-jooq-with-spring-code-generation.html","url":"https:\/\/www.javacodegeeks.com\/2014\/02\/using-jooq-with-spring-code-generation.html","name":"Using jOOQ with Spring: Code Generation","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/02\/using-jooq-with-spring-code-generation.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/02\/using-jooq-with-spring-code-generation.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2015\/03\/jooq-2-logo.jpg","datePublished":"2014-02-03T08:00:22+00:00","description":"As we might remember from the first part of this tutorial, jOOQ states that jOOQ generates Java code from your database and lets you build typesafe SQL","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/02\/using-jooq-with-spring-code-generation.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2014\/02\/using-jooq-with-spring-code-generation.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2014\/02\/using-jooq-with-spring-code-generation.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2015\/03\/jooq-2-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2015\/03\/jooq-2-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2014\/02\/using-jooq-with-spring-code-generation.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Using jOOQ with Spring: Code Generation"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/5af4df3fdfeb79e9fa3598d79bff2c9e","name":"Petri Kainulainen","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/9e57425180f323fa65bc519a64c8273d3fcb7c6bd272e56b37dd15613f403659?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/9e57425180f323fa65bc519a64c8273d3fcb7c6bd272e56b37dd15613f403659?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9e57425180f323fa65bc519a64c8273d3fcb7c6bd272e56b37dd15613f403659?s=96&d=mm&r=g","caption":"Petri Kainulainen"},"description":"Petri is passionate about software development and continuous improvement. He is specialized in software development with the Spring Framework and is the author of Spring Data book.","sameAs":["http:\/\/www.petrikainulainen.net\/","http:\/\/www.linkedin.com\/in\/petrikainulainen","https:\/\/x.com\/https:\/\/twitter.com\/petrikainulaine"],"url":"https:\/\/www.javacodegeeks.com\/author\/petri-kainulainen"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/20847","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/429"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=20847"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/20847\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/38135"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=20847"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=20847"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=20847"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}