Release 2.0.4 - Updated manual

This commit is contained in:
Lukas Eder 2012-02-12 16:15:07 +00:00
parent f292c9e583
commit 6291dca929
10 changed files with 745 additions and 275 deletions

View File

@ -26,6 +26,9 @@ generation. These improvements include:
and to annotate both POJOs and Records with JPA annotations
such as @Entity, @Table, @Id, @Column, @UniqueConstraint, etc.
You can migrate your existing .properties configuration by running
> org.jooq.util.GenerationTool /your.properties migrate
Besides that, there is a lot of ongoing work to improve the
integration of Oracle's TABLE and VARRAY types.

View File

@ -26,6 +26,9 @@ generation. These improvements include:
and to annotate both POJOs and Records with JPA annotations
such as @Entity, @Table, @Id, @Column, @UniqueConstraint, etc.
You can migrate your existing .properties configuration by running
> org.jooq.util.GenerationTool /your.properties migrate
Besides that, there is a lot of ongoing work to improve the
integration of Oracle's TABLE and VARRAY types.

View File

@ -1859,7 +1859,7 @@ i.execute();</fo:block>
<fo:block font-size="11pt">In some occasions, you may prefer the INSERT SELECT syntax, for instance, when
you copy records from one table to another: </fo:block>
<fo:block font-family="Courier" linefeed-treatment="preserve" white-space-collapse="false" white-space-treatment="preserve" font-size="6pt" margin="12pt" padding="4pt" border="2px solid #882222" background-color="#FFEEDD" page-break-inside="avoid">Insert i = create.insertInto(T_AUTHOR_ARCHIVE)
.select(create.selectFrom(T_AUTHOR).where(T_AUTHOR.DECEASED.equal(1)));
.select(create.selectFrom(T_AUTHOR).where(T_AUTHOR.DECEASED.isTrue()));
i.execute();</fo:block>
@ -2078,6 +2078,8 @@ Object[] fetchArray(String fieldName);
<fo:block font-family="Courier" linefeed-treatment="preserve" white-space-collapse="false" white-space-treatment="preserve" font-size="6pt" margin="12pt" padding="4pt" border="2px solid #882222" background-color="#FFEEDD" page-break-inside="avoid"><![CDATA[// Fetch the resulting records into a custom POJO
// type, which may or may not be JPA-annotated
// Use the generator's <pojos>true</pojos> and <jpaAnnotation>true</jpaAnnotation>
// configurations to generate such POJOs with jOOQ
<E> List<E> fetchInto(Class<? extends E> type);
// Fetch the resulting records into a custom
@ -2558,86 +2560,183 @@ public void bind(BindContext context) throws DataAccessException;</fo:block>
</fo:block>
<fo:block font-family="Georgia" font-size="16pt" padding-top="10pt" padding-bottom="10pt" page-break-after="avoid">Configure jOOQ</fo:block>
<fo:block font-family="Georgia" font-size="16pt" padding-top="10pt" padding-bottom="10pt" page-break-after="avoid">Configure jOOQ's code generator</fo:block>
<fo:block font-size="11pt">You need to tell jOOQ some things about your database connection.
Here's an example of how to do it for a MySQL database </fo:block>
<fo:block font-family="Courier" linefeed-treatment="preserve" white-space-collapse="false" white-space-treatment="preserve" font-size="6pt" margin="12pt" padding="4pt" border="2px solid #882222" background-color="#FFEEDD" page-break-inside="avoid">#Configure the database connection here
jdbc.Driver=com.mysql.jdbc.Driver
jdbc.URL=jdbc:mysql://[your jdbc URL]
jdbc.User=[your database user]
jdbc.Password=[your database password]
Here's an example of how to do it for an Oracle database </fo:block>
<fo:block font-family="Courier" linefeed-treatment="preserve" white-space-collapse="false" white-space-treatment="preserve" font-size="6pt" margin="12pt" padding="4pt" border="2px solid #882222" background-color="#FFEEDD" page-break-inside="avoid"><![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration>
<!-- Configure the database connection here -->
<jdbc>
<driver>oracle.jdbc.OracleDriver</driver>
<url>jdbc:oracle:thin:@[your jdbc connection parameters]</url>
<user>[your database user]</user>
<password>[your database password]</password>
</jdbc>
#The default code generator. You can override this one, to generate your own code style
#Defaults to org.jooq.util.DefaultGenerator
generator=org.jooq.util.DefaultGenerator
<generator>
<!-- The default code generator. You can override this one, to generate your own code style
Defaults to org.jooq.util.DefaultGenerator -->
<name>org.jooq.util.DefaultGenerator</name>
#The database type. The format here is:
#generator.database=org.util.[database].[database]Database
generator.database=org.jooq.util.mysql.MySQLDatabase
<!-- The naming strategy used for class and field names.
You may override this with your custom naming strategy.
Defaults to org.jooq.util.DefaultGeneratorStrategy -->
<strategy>
<name>org.jooq.util.DefaultGeneratorStrategy</name>
</strategy>
#The schema that is used locally as a source for meta information. This could be your
#development schema or the production schema, etc:
generator.database.input-schema=[your database schema / owner / name]
<database>
<!-- The database dialect from jooq-meta. Available dialects are
named org.util.[database].[database]Database. Known values are:
#All elements that are generated from your schema (several Java regular expressions, separated by comma)
#Watch out for case-sensitivity. Depending on your database, this might be important!
#You can create case-insensitive regular expressions using this syntax: (?i:expr)
generator.database.includes=.*
org.jooq.util.ase.ASEDatabase
org.jooq.util.db2.DB2Database
org.jooq.util.derby.DerbyDatabase
org.jooq.util.h2.H2Database
org.jooq.util.hsqldb.HSQLDBDatabase
org.jooq.util.ingres.IngresDatabase
org.jooq.util.mysql.MySQLDatabase
org.jooq.util.oracle.OracleDatabase
org.jooq.util.postgres.PostgresDatabase
org.jooq.util.sqlite.SQLiteDatabaes
org.jooq.util.sqlserver.SQLServerDatabase
org.jooq.util.sybase.SybaseDatabase
#All elements that are excluded from your schema (several Java regular expressions, separated by comma). Excludes match before includes
generator.database.excludes=
You can also provide your own org.jooq.util.Database implementation
here, if your database is currently not supported -->
<name>org.jooq.util.oracle.OracleDatabase</name>
#Primary key / foreign key relations should be generated and used.
#This will be a prerequisite for various advanced features
#Defaults to false
generator.generate.relations=true
<!-- All elements that are generated from your schema (several Java
regular expressions, separated by comma) Watch out for
case-sensitivity. Depending on your database, this might be
important! You can create case-insensitive regular expressions
using this syntax: (?i:expr)A comma-separated list of regular
expressions -->
<includes>.*</includes>
#Generate deprecated code for backwards compatibility
#Defaults to true
generator.generate.deprecated=false
<!-- All elements that are excluded from your schema (several Java
regular expressions, separated by comma). Excludes match before
includes -->
<excludes></excludes>
#The destination package of your generated classes (within the destination directory)
generator.target.package=[org.jooq.your.package]
<!-- The schema that is used locally as a source for meta information.
This could be your development schema or the production schema, etc
This cannot be combined with the schemata element. -->
<inputSchema>[your database schema / owner / name]</inputSchema>
</database>
#The destination directory of your generated classes
generator.target.directory=[/path/to/your/dir]</fo:block>
<generate>
<!-- See advanced configuration properties -->
</generate>
<fo:block font-size="11pt">And you can add some optional advanced configuration parameters: </fo:block>
<fo:block font-family="Courier" linefeed-treatment="preserve" white-space-collapse="false" white-space-treatment="preserve" font-size="6pt" margin="12pt" padding="4pt" border="2px solid #882222" background-color="#FFEEDD" page-break-inside="avoid">#The schema that is used in generated source code. This will be the production schema
#Use this to override your local development schema name for source code generation
#If not specified, this will be the same as the input-schema.
generator.database.output-schema=[your database schema / owner / name]
<target>
<!-- The destination package of your generated classes (within the
destination directory) -->
<packageName>[org.jooq.your.packagename]</packageName>
#Generate java.sql.Timestamp fields for DATE columns. This is particularly useful for Oracle databases
#Defaults to false
generator.database.date-as-timestamp=true
<!-- The destination directory of your generated classes -->
<directory>[/path/to/your/dir]</directory>
</target>
</generator>
</configuration>]]></fo:block>
#Generate instance fields in your tables, as opposed to static fields. This simplifies aliasing
#Defaults to true
generator.generate.instance-fields=true
<fo:block font-size="11pt">And you can add some optional advanced configuration parameters for the database: </fo:block>
#Generate the javax.annotation.Generated annotation to indicate jOOQ version used for source code
#generation. Defaults to true
generator.generate.generated-annotation=true
<fo:block font-family="Courier" linefeed-treatment="preserve" white-space-collapse="false" white-space-treatment="preserve" font-size="6pt" margin="12pt" padding="4pt" border="2px solid #882222" background-color="#FFEEDD" page-break-inside="avoid"><![CDATA[<!-- These properties can be added to the database element: -->
<database>
<!-- Generate java.sql.Timestamp fields for DATE columns. This is
particularly useful for Oracle databases.
Defaults to false -->
<dateAsTimestamp>false</dateAsTimestamp>
#Generate jOOU data types for your unsigned data types, which are not natively supported in Java
#Defaults to true
generator.generate.unsigned-types=true
<!-- Generate jOOU data types for your unsigned data types, which are
not natively supported in Java.
Defaults to true -->
<unsignedTypes>true</unsignedTypes>
#Generate a master data table enum classes (several Java regular expressions, separated by comma)
generator.generate.master-data-tables=[a list of tables]
<!-- The schema that is used in generated source code. This will be the
production schema. Use this to override your local development
schema name for source code generation. If not specified, this
will be the same as the input-schema. -->
<outputSchema>[your database schema / owner / name]</outputSchema>
<!-- A configuration element to configure several input and/or output
schemata for jooq-meta, in case you're using jooq-meta in a multi-
schema environment.
This cannot be combined with the above inputSchema / outputSchema -->
<schemata>
<schema>
<inputSchema>...</inputSchema>
<outputSchema>...</outputSchema>
</schema>
[ <schema>...</schema> ... ]
</schemata>
<!-- A configuration element to configure master data table enum classes -->
<masterDataTables>...</masterDataTables>
<!-- A configuration element to configure synthetic enum types
This is EXPERIMENTAL functionality. Use at your own risk -->
<enumTypes>...</enumTypes>
<!-- A configuration element to configure type overrides for generated
artefacts (e.g. in combination with enumTypes)
This is EXPERIMENTAL functionality. Use at your own risk -->
<forcedTypes>...</forcedTypes>
</database>]]></fo:block>
<fo:block font-size="11pt">Also, you can add some optional advanced configuration parameters for the generator: </fo:block>
<fo:block font-family="Courier" linefeed-treatment="preserve" white-space-collapse="false" white-space-treatment="preserve" font-size="6pt" margin="12pt" padding="4pt" border="2px solid #882222" background-color="#FFEEDD" page-break-inside="avoid"><![CDATA[<!-- These properties can be added to the generate element: -->
<generate>
<!-- Primary key / foreign key relations should be generated and used.
This is a prerequisite for various advanced features.
Defaults to false -->
<relations>false</relations>
<!-- Generate navigation methods to navigate foreign key relationships
directly from Record classes. This is only relevant if relations
is set to true, too.
Defaults to true -->
<navigationMethods>true</navigationMethods>
<!-- Generate deprecated code for backwards compatibility
Defaults to true -->
<deprecated>true</deprecated>
<!-- Generate instance fields in your tables, as opposed to static
fields. This simplifies aliasing.
Defaults to true -->
<instanceFields>true</instanceFields>
<!-- Generate the javax.annotation.Generated annotation to indicate
jOOQ version used for source code.
Defaults to true -->
<generatedAnnotation>true</generatedAnnotation>
<!-- Generate POJOs in addition to Record classes for usage of the
ResultQuery.fetchInto(Class) API
Defaults to false -->
<pojos>false</pojos>
<!-- Annotate POJOs and Records with JPA annotations for increased
compatibility and better integration with JPA/Hibernate, etc
Defaults to false -->
<jpaAnnotations>false</jpaAnnotations>
</generate>]]></fo:block>
#For every master data table, specify two special columns
generator.generate.master-data-table-literal.[master data table]=[column used for enum literals]
generator.generate.master-data-table-description.[master data table]=[column used for documentation]</fo:block>
<fo:block font-size="11pt">Check out the manual's section about
<fo:basic-link font-size="11pt" color="#882222" font-weight="bold" text-shadow="0 1px 2px #666666" internal-destination="MasterData">master data</fo:basic-link>
to find out more
about those advanced configuration parameters. </fo:block>
<fo:block font-size="11pt">Also, check out the official XSD file at
<fo:basic-link font-size="11pt" color="#882222" font-weight="bold" text-shadow="0 1px 2px #666666" external-destination="url('http://www.jooq.org/xsd/jooq-codegen-2.0.4.xsd')">http://www.jooq.org/xsd/jooq-codegen-2.0.4.xsd</fo:basic-link>
for a formal specification</fo:block>
<fo:block font-family="Georgia" font-size="16pt" padding-top="10pt" padding-bottom="10pt" page-break-after="avoid">Run jOOQ code generation</fo:block>
<fo:block font-size="11pt">Code generation works by calling this class with the above property file as argument.</fo:block>
<fo:block font-family="Courier" linefeed-treatment="preserve" white-space-collapse="false" white-space-treatment="preserve" font-size="6pt" margin="12pt" padding="4pt" border="2px solid #882222" background-color="#FFEEDD" page-break-inside="avoid">org.jooq.util.GenerationTool /jooq-config.properties</fo:block>
<fo:block font-family="Courier" linefeed-treatment="preserve" white-space-collapse="false" white-space-treatment="preserve" font-size="6pt" margin="12pt" padding="4pt" border="2px solid #882222" background-color="#FFEEDD" page-break-inside="avoid">org.jooq.util.GenerationTool /jooq-config.xml</fo:block>
<fo:block font-size="11pt">Be sure that these elements are located on the classpath: </fo:block>
<fo:block padding-top="16pt" padding-bottom="16pt" page-break-inside="avoid">
<fo:list-block>
@ -2830,13 +2929,6 @@ generator.generate.master-data-table-description.[master data table]=[column use
<packageName>org.jooq.util.maven.example</packageName>
<directory>target/generated-sources/jooq</directory>
</target>
<masterDataTables>
<masterDataTable>
<name>t_language</name>
<literal>cd</literal>
<description>description</description>
</masterDataTable>
</masterDataTables>
</generator>
</configuration>
</plugin>
@ -2845,6 +2937,19 @@ generator.generate.master-data-table-description.[master data table]=[column use
<fo:basic-link font-size="11pt" color="#882222" font-weight="bold" text-shadow="0 1px 2px #666666" external-destination="url('https://github.com/lukaseder/jOOQ/blob/master/jOOQ-codegen-maven-example/pom.xml')">https://github.com/lukaseder/jOOQ/blob/master/jOOQ-codegen-maven-example/pom.xml</fo:basic-link>
</fo:block>
<fo:block font-family="Georgia" font-size="16pt" padding-top="10pt" padding-bottom="10pt" page-break-after="avoid">Migrate properties files from jOOQ 1.7, early versions of jOOQ 2.0.x:</fo:block>
<fo:block font-size="11pt">
Before jOOQ 2.0.4, the code generator was configured using properties files
These files are still supported for source code generation, but their syntax
won't be maintained any longer. If you wish to migrate to XML, you can
migrate the file using this command on the command line
</fo:block>
<fo:block font-family="Courier" linefeed-treatment="preserve" white-space-collapse="false" white-space-treatment="preserve" font-size="6pt" margin="12pt" padding="4pt" border="2px solid #882222" background-color="#FFEEDD" page-break-inside="avoid">org.jooq.util.GenerationTool /jooq-config.properties migrate</fo:block>
<fo:block font-size="11pt">
Using the migrate flag, jOOQ will read the properties file and output
a corresponding XML file on system out
</fo:block>
<fo:block font-family="Georgia" font-size="16pt" padding-top="10pt" padding-bottom="10pt" page-break-after="avoid">Use jOOQ generated classes in your application</fo:block>
<fo:block font-size="11pt">Be sure, both jOOQ.jar and your generated package (see
configuration) are located on your classpath. Once this is done, you
@ -5325,12 +5430,23 @@ create.select(LAST_NAME, COUNT1, COUNT2)
<fo:block font-size="11pt">As previously discussed in the
<fo:basic-link font-size="11pt" color="#882222" font-weight="bold" text-shadow="0 1px 2px #666666" internal-destination="Configuration">configuration and setup</fo:basic-link>
section, you can configure master data tables as follows: </fo:block>
<fo:block font-family="Courier" linefeed-treatment="preserve" white-space-collapse="false" white-space-treatment="preserve" font-size="6pt" margin="12pt" padding="4pt" border="2px solid #882222" background-color="#FFEEDD" page-break-inside="avoid">#Generate a master data table enum classes (several Java regular expressions, separated by comma)
generator.generate.master-data-tables=[a list of tables]
<fo:block font-family="Courier" linefeed-treatment="preserve" white-space-collapse="false" white-space-treatment="preserve" font-size="6pt" margin="12pt" padding="4pt" border="2px solid #882222" background-color="#FFEEDD" page-break-inside="avoid"><![CDATA[<!-- These properties can be added to the database element: -->
<database>
<masterDataTables>
<masterDataTable>
<!-- The name of a master data table -->
<name>[a table name]</name>
#For every master data table, specify two special columns
generator.generate.master-data-table-literal.[master data table]=[column used for enum literals]
generator.generate.master-data-table-description.[master data table]=[column used for documentation]</fo:block>
<!-- The column used for enum literals -->
<literal>[a column name]</literal>
<!-- The column used for documentation -->
<description>[a column name]</description>
</masterDataTable>
[ <masterDataTable>...</masterDataTable> ... ]
</masterDataTables>
</database>]]></fo:block>
<fo:block font-size="11pt">The results of this will be a Java enum that looks similar to this: </fo:block>
<fo:block font-family="Courier" linefeed-treatment="preserve" white-space-collapse="false" white-space-treatment="preserve" font-size="6pt" margin="12pt" padding="4pt" border="2px solid #882222" background-color="#FFEEDD" page-break-inside="avoid"><![CDATA[public enum TLanguage implements MasterDataType<Integer> {

View File

@ -1030,7 +1030,7 @@ i.execute();</pre>
<p>In some occasions, you may prefer the INSERT SELECT syntax, for instance, when
you copy records from one table to another: </p>
<pre class="prettyprint lang-java">Insert i = create.insertInto(T_AUTHOR_ARCHIVE)
.select(create.selectFrom(T_AUTHOR).where(T_AUTHOR.DECEASED.equal(1)));
.select(create.selectFrom(T_AUTHOR).where(T_AUTHOR.DECEASED.isTrue()));
i.execute();</pre>
@ -1210,6 +1210,8 @@ Object[] fetchArray(String fieldName);
<pre class="prettyprint lang-java">// Fetch the resulting records into a custom POJO
// type, which may or may not be JPA-annotated
// Use the generator's &lt;pojos&gt;true&lt;/pojos&gt; and &lt;jpaAnnotation&gt;true&lt;/jpaAnnotation&gt;
// configurations to generate such POJOs with jOOQ
&lt;E&gt; List&lt;E&gt; fetchInto(Class&lt;? extends E&gt; type);
// Fetch the resulting records into a custom
@ -1605,86 +1607,183 @@ public void bind(BindContext context) throws DataAccessException;</pre>
</p>
<h2>Configure jOOQ</h2>
<h2>Configure jOOQ's code generator</h2>
<p>You need to tell jOOQ some things about your database connection.
Here's an example of how to do it for a MySQL database </p>
<pre class="prettyprint">#Configure the database connection here
jdbc.Driver=com.mysql.jdbc.Driver
jdbc.URL=jdbc:mysql://[your jdbc URL]
jdbc.User=[your database user]
jdbc.Password=[your database password]
Here's an example of how to do it for an Oracle database </p>
<pre class="prettyprint lang-xml">&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
&lt;configuration&gt;
&lt;!-- Configure the database connection here --&gt;
&lt;jdbc&gt;
&lt;driver&gt;oracle.jdbc.OracleDriver&lt;/driver&gt;
&lt;url&gt;jdbc:oracle:thin:@[your jdbc connection parameters]&lt;/url&gt;
&lt;user&gt;[your database user]&lt;/user&gt;
&lt;password&gt;[your database password]&lt;/password&gt;
&lt;/jdbc&gt;
#The default code generator. You can override this one, to generate your own code style
#Defaults to org.jooq.util.DefaultGenerator
generator=org.jooq.util.DefaultGenerator
&lt;generator&gt;
&lt;!-- The default code generator. You can override this one, to generate your own code style
Defaults to org.jooq.util.DefaultGenerator --&gt;
&lt;name&gt;org.jooq.util.DefaultGenerator&lt;/name&gt;
#The database type. The format here is:
#generator.database=org.util.[database].[database]Database
generator.database=org.jooq.util.mysql.MySQLDatabase
&lt;!-- The naming strategy used for class and field names.
You may override this with your custom naming strategy.
Defaults to org.jooq.util.DefaultGeneratorStrategy --&gt;
&lt;strategy&gt;
&lt;name&gt;org.jooq.util.DefaultGeneratorStrategy&lt;/name&gt;
&lt;/strategy&gt;
#The schema that is used locally as a source for meta information. This could be your
#development schema or the production schema, etc:
generator.database.input-schema=[your database schema / owner / name]
&lt;database&gt;
&lt;!-- The database dialect from jooq-meta. Available dialects are
named org.util.[database].[database]Database. Known values are:
#All elements that are generated from your schema (several Java regular expressions, separated by comma)
#Watch out for case-sensitivity. Depending on your database, this might be important!
#You can create case-insensitive regular expressions using this syntax: (?i:expr)
generator.database.includes=.*
org.jooq.util.ase.ASEDatabase
org.jooq.util.db2.DB2Database
org.jooq.util.derby.DerbyDatabase
org.jooq.util.h2.H2Database
org.jooq.util.hsqldb.HSQLDBDatabase
org.jooq.util.ingres.IngresDatabase
org.jooq.util.mysql.MySQLDatabase
org.jooq.util.oracle.OracleDatabase
org.jooq.util.postgres.PostgresDatabase
org.jooq.util.sqlite.SQLiteDatabaes
org.jooq.util.sqlserver.SQLServerDatabase
org.jooq.util.sybase.SybaseDatabase
#All elements that are excluded from your schema (several Java regular expressions, separated by comma). Excludes match before includes
generator.database.excludes=
You can also provide your own org.jooq.util.Database implementation
here, if your database is currently not supported --&gt;
&lt;name&gt;org.jooq.util.oracle.OracleDatabase&lt;/name&gt;
#Primary key / foreign key relations should be generated and used.
#This will be a prerequisite for various advanced features
#Defaults to false
generator.generate.relations=true
&lt;!-- All elements that are generated from your schema (several Java
regular expressions, separated by comma) Watch out for
case-sensitivity. Depending on your database, this might be
important! You can create case-insensitive regular expressions
using this syntax: (?i:expr)A comma-separated list of regular
expressions --&gt;
&lt;includes&gt;.*&lt;/includes&gt;
#Generate deprecated code for backwards compatibility
#Defaults to true
generator.generate.deprecated=false
&lt;!-- All elements that are excluded from your schema (several Java
regular expressions, separated by comma). Excludes match before
includes --&gt;
&lt;excludes&gt;&lt;/excludes&gt;
#The destination package of your generated classes (within the destination directory)
generator.target.package=[org.jooq.your.package]
&lt;!-- The schema that is used locally as a source for meta information.
This could be your development schema or the production schema, etc
This cannot be combined with the schemata element. --&gt;
&lt;inputSchema&gt;[your database schema / owner / name]&lt;/inputSchema&gt;
&lt;/database&gt;
#The destination directory of your generated classes
generator.target.directory=[/path/to/your/dir]</pre>
&lt;generate&gt;
&lt;!-- See advanced configuration properties --&gt;
&lt;/generate&gt;
<p>And you can add some optional advanced configuration parameters: </p>
<pre class="prettyprint">#The schema that is used in generated source code. This will be the production schema
#Use this to override your local development schema name for source code generation
#If not specified, this will be the same as the input-schema.
generator.database.output-schema=[your database schema / owner / name]
&lt;target&gt;
&lt;!-- The destination package of your generated classes (within the
destination directory) --&gt;
&lt;packageName&gt;[org.jooq.your.packagename]&lt;/packageName&gt;
#Generate java.sql.Timestamp fields for DATE columns. This is particularly useful for Oracle databases
#Defaults to false
generator.database.date-as-timestamp=true
&lt;!-- The destination directory of your generated classes --&gt;
&lt;directory&gt;[/path/to/your/dir]&lt;/directory&gt;
&lt;/target&gt;
&lt;/generator&gt;
&lt;/configuration&gt;</pre>
#Generate instance fields in your tables, as opposed to static fields. This simplifies aliasing
#Defaults to true
generator.generate.instance-fields=true
<p>And you can add some optional advanced configuration parameters for the database: </p>
#Generate the javax.annotation.Generated annotation to indicate jOOQ version used for source code
#generation. Defaults to true
generator.generate.generated-annotation=true
<pre class="prettyprint lang-xml">&lt;!-- These properties can be added to the database element: --&gt;
&lt;database&gt;
&lt;!-- Generate java.sql.Timestamp fields for DATE columns. This is
particularly useful for Oracle databases.
Defaults to false --&gt;
&lt;dateAsTimestamp&gt;false&lt;/dateAsTimestamp&gt;
#Generate jOOU data types for your unsigned data types, which are not natively supported in Java
#Defaults to true
generator.generate.unsigned-types=true
&lt;!-- Generate jOOU data types for your unsigned data types, which are
not natively supported in Java.
Defaults to true --&gt;
&lt;unsignedTypes&gt;true&lt;/unsignedTypes&gt;
#Generate a master data table enum classes (several Java regular expressions, separated by comma)
generator.generate.master-data-tables=[a list of tables]
&lt;!-- The schema that is used in generated source code. This will be the
production schema. Use this to override your local development
schema name for source code generation. If not specified, this
will be the same as the input-schema. --&gt;
&lt;outputSchema&gt;[your database schema / owner / name]&lt;/outputSchema&gt;
&lt;!-- A configuration element to configure several input and/or output
schemata for jooq-meta, in case you're using jooq-meta in a multi-
schema environment.
This cannot be combined with the above inputSchema / outputSchema --&gt;
&lt;schemata&gt;
&lt;schema&gt;
&lt;inputSchema&gt;...&lt;/inputSchema&gt;
&lt;outputSchema&gt;...&lt;/outputSchema&gt;
&lt;/schema&gt;
[ &lt;schema&gt;...&lt;/schema&gt; ... ]
&lt;/schemata&gt;
&lt;!-- A configuration element to configure master data table enum classes --&gt;
&lt;masterDataTables&gt;...&lt;/masterDataTables&gt;
&lt;!-- A configuration element to configure synthetic enum types
This is EXPERIMENTAL functionality. Use at your own risk --&gt;
&lt;enumTypes&gt;...&lt;/enumTypes&gt;
&lt;!-- A configuration element to configure type overrides for generated
artefacts (e.g. in combination with enumTypes)
This is EXPERIMENTAL functionality. Use at your own risk --&gt;
&lt;forcedTypes&gt;...&lt;/forcedTypes&gt;
&lt;/database&gt;</pre>
<p>Also, you can add some optional advanced configuration parameters for the generator: </p>
<pre class="prettyprint lang-xml">&lt;!-- These properties can be added to the generate element: --&gt;
&lt;generate&gt;
&lt;!-- Primary key / foreign key relations should be generated and used.
This is a prerequisite for various advanced features.
Defaults to false --&gt;
&lt;relations&gt;false&lt;/relations&gt;
&lt;!-- Generate navigation methods to navigate foreign key relationships
directly from Record classes. This is only relevant if relations
is set to true, too.
Defaults to true --&gt;
&lt;navigationMethods&gt;true&lt;/navigationMethods&gt;
&lt;!-- Generate deprecated code for backwards compatibility
Defaults to true --&gt;
&lt;deprecated&gt;true&lt;/deprecated&gt;
&lt;!-- Generate instance fields in your tables, as opposed to static
fields. This simplifies aliasing.
Defaults to true --&gt;
&lt;instanceFields&gt;true&lt;/instanceFields&gt;
&lt;!-- Generate the javax.annotation.Generated annotation to indicate
jOOQ version used for source code.
Defaults to true --&gt;
&lt;generatedAnnotation&gt;true&lt;/generatedAnnotation&gt;
&lt;!-- Generate POJOs in addition to Record classes for usage of the
ResultQuery.fetchInto(Class) API
Defaults to false --&gt;
&lt;pojos&gt;false&lt;/pojos&gt;
&lt;!-- Annotate POJOs and Records with JPA annotations for increased
compatibility and better integration with JPA/Hibernate, etc
Defaults to false --&gt;
&lt;jpaAnnotations&gt;false&lt;/jpaAnnotations&gt;
&lt;/generate&gt;</pre>
#For every master data table, specify two special columns
generator.generate.master-data-table-literal.[master data table]=[column used for enum literals]
generator.generate.master-data-table-description.[master data table]=[column used for documentation]</pre>
<p>Check out the manual's section about
<a href="#MasterData" title="jOOQ Manual reference: Master data generation. Enumeration tables">master data</a>
to find out more
about those advanced configuration parameters. </p>
<p>Also, check out the official XSD file at
<a href="http://www.jooq.org/xsd/jooq-codegen-2.0.4.xsd" title="The jOOQ-codegen configuration XSD">http://www.jooq.org/xsd/jooq-codegen-2.0.4.xsd</a>
for a formal specification</p>
<h2>Run jOOQ code generation</h2>
<p>Code generation works by calling this class with the above property file as argument.</p>
<pre class="prettyprint">org.jooq.util.GenerationTool /jooq-config.properties</pre>
<pre class="prettyprint">org.jooq.util.GenerationTool /jooq-config.xml</pre>
<p>Be sure that these elements are located on the classpath: </p>
<ul>
@ -1834,13 +1933,6 @@ generator.generate.master-data-table-description.[master data table]=[column use
&lt;packageName&gt;org.jooq.util.maven.example&lt;/packageName&gt;
&lt;directory&gt;target/generated-sources/jooq&lt;/directory&gt;
&lt;/target&gt;
&lt;masterDataTables&gt;
&lt;masterDataTable&gt;
&lt;name&gt;t_language&lt;/name&gt;
&lt;literal&gt;cd&lt;/literal&gt;
&lt;description&gt;description&lt;/description&gt;
&lt;/masterDataTable&gt;
&lt;/masterDataTables&gt;
&lt;/generator&gt;
&lt;/configuration&gt;
&lt;/plugin&gt;
@ -1849,6 +1941,19 @@ generator.generate.master-data-table-description.[master data table]=[column use
<a href="https://github.com/lukaseder/jOOQ/blob/master/jOOQ-codegen-maven-example/pom.xml" title="jOOQ-codegen-maven example pom.xml file">https://github.com/lukaseder/jOOQ/blob/master/jOOQ-codegen-maven-example/pom.xml</a>
</p>
<h3>Migrate properties files from jOOQ 1.7, early versions of jOOQ 2.0.x:</h3>
<p>
Before jOOQ 2.0.4, the code generator was configured using properties files
These files are still supported for source code generation, but their syntax
won't be maintained any longer. If you wish to migrate to XML, you can
migrate the file using this command on the command line
</p>
<pre class="prettyprint">org.jooq.util.GenerationTool /jooq-config.properties migrate</pre>
<p>
Using the migrate flag, jOOQ will read the properties file and output
a corresponding XML file on system out
</p>
<h3>Use jOOQ generated classes in your application</h3>
<p>Be sure, both jOOQ.jar and your generated package (see
configuration) are located on your classpath. Once this is done, you
@ -3919,12 +4024,23 @@ create.select(LAST_NAME, COUNT1, COUNT2)
<p>As previously discussed in the
<a href="#Configuration" title="jOOQ Manual reference: Configuration and setup of the generator">configuration and setup</a>
section, you can configure master data tables as follows: </p>
<pre class="prettyprint">#Generate a master data table enum classes (several Java regular expressions, separated by comma)
generator.generate.master-data-tables=[a list of tables]
<pre class="prettyprint lang-xml">&lt;!-- These properties can be added to the database element: --&gt;
&lt;database&gt;
&lt;masterDataTables&gt;
&lt;masterDataTable&gt;
&lt;!-- The name of a master data table --&gt;
&lt;name&gt;[a table name]&lt;/name&gt;
#For every master data table, specify two special columns
generator.generate.master-data-table-literal.[master data table]=[column used for enum literals]
generator.generate.master-data-table-description.[master data table]=[column used for documentation]</pre>
&lt;!-- The column used for enum literals --&gt;
&lt;literal&gt;[a column name]&lt;/literal&gt;
&lt;!-- The column used for documentation --&gt;
&lt;description&gt;[a column name]&lt;/description&gt;
&lt;/masterDataTable&gt;
[ &lt;masterDataTable&gt;...&lt;/masterDataTable&gt; ... ]
&lt;/masterDataTables&gt;
&lt;/database&gt;</pre>
<p>The results of this will be a Java enum that looks similar to this: </p>
<pre class="prettyprint lang-java">public enum TLanguage implements MasterDataType&lt;Integer&gt; {

View File

@ -36,12 +36,23 @@ function printContent() {
<p>As previously discussed in the
<a href="<?=$root?>/manual/META/Configuration/" title="jOOQ Manual reference: Configuration and setup of the generator">configuration and setup</a>
section, you can configure master data tables as follows: </p>
<pre class="prettyprint">#Generate a master data table enum classes (several Java regular expressions, separated by comma)
generator.generate.master-data-tables=[a list of tables]
<pre class="prettyprint lang-xml">&lt;!-- These properties can be added to the database element: --&gt;
&lt;database&gt;
&lt;masterDataTables&gt;
&lt;masterDataTable&gt;
&lt;!-- The name of a master data table --&gt;
&lt;name&gt;[a table name]&lt;/name&gt;
#For every master data table, specify two special columns
generator.generate.master-data-table-literal.[master data table]=[column used for enum literals]
generator.generate.master-data-table-description.[master data table]=[column used for documentation]</pre>
&lt;!-- The column used for enum literals --&gt;
&lt;literal&gt;[a column name]&lt;/literal&gt;
&lt;!-- The column used for documentation --&gt;
&lt;description&gt;[a column name]&lt;/description&gt;
&lt;/masterDataTable&gt;
[ &lt;masterDataTable&gt;...&lt;/masterDataTable&gt; ... ]
&lt;/masterDataTables&gt;
&lt;/database&gt;</pre>
<p>The results of this will be a Java enum that looks similar to this: </p>
<pre class="prettyprint lang-java">public enum TLanguage implements MasterDataType&lt;Integer&gt; {

View File

@ -312,7 +312,7 @@ i.execute();</pre>
<p>In some occasions, you may prefer the INSERT SELECT syntax, for instance, when
you copy records from one table to another: </p>
<pre class="prettyprint lang-java">Insert i = create.insertInto(T_AUTHOR_ARCHIVE)
.select(create.selectFrom(T_AUTHOR).where(T_AUTHOR.DECEASED.equal(1)));
.select(create.selectFrom(T_AUTHOR).where(T_AUTHOR.DECEASED.isTrue()));
i.execute();</pre>

View File

@ -75,6 +75,8 @@ Object[] fetchArray(String fieldName);
<pre class="prettyprint lang-java">// Fetch the resulting records into a custom POJO
// type, which may or may not be JPA-annotated
// Use the generator's &lt;pojos&gt;true&lt;/pojos&gt; and &lt;jpaAnnotation&gt;true&lt;/jpaAnnotation&gt;
// configurations to generate such POJOs with jOOQ
&lt;E&gt; List&lt;E&gt; fetchInto(Class&lt;? extends E&gt; type);
// Fetch the resulting records into a custom

View File

@ -71,86 +71,183 @@ function printContent() {
</p>
<h2>Configure jOOQ</h2>
<h2>Configure jOOQ's code generator</h2>
<p>You need to tell jOOQ some things about your database connection.
Here's an example of how to do it for a MySQL database </p>
<pre class="prettyprint">#Configure the database connection here
jdbc.Driver=com.mysql.jdbc.Driver
jdbc.URL=jdbc:mysql://[your jdbc URL]
jdbc.User=[your database user]
jdbc.Password=[your database password]
Here's an example of how to do it for an Oracle database </p>
<pre class="prettyprint lang-xml">&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
&lt;configuration&gt;
&lt;!-- Configure the database connection here --&gt;
&lt;jdbc&gt;
&lt;driver&gt;oracle.jdbc.OracleDriver&lt;/driver&gt;
&lt;url&gt;jdbc:oracle:thin:@[your jdbc connection parameters]&lt;/url&gt;
&lt;user&gt;[your database user]&lt;/user&gt;
&lt;password&gt;[your database password]&lt;/password&gt;
&lt;/jdbc&gt;
#The default code generator. You can override this one, to generate your own code style
#Defaults to org.jooq.util.DefaultGenerator
generator=org.jooq.util.DefaultGenerator
&lt;generator&gt;
&lt;!-- The default code generator. You can override this one, to generate your own code style
Defaults to org.jooq.util.DefaultGenerator --&gt;
&lt;name&gt;org.jooq.util.DefaultGenerator&lt;/name&gt;
#The database type. The format here is:
#generator.database=org.util.[database].[database]Database
generator.database=org.jooq.util.mysql.MySQLDatabase
&lt;!-- The naming strategy used for class and field names.
You may override this with your custom naming strategy.
Defaults to org.jooq.util.DefaultGeneratorStrategy --&gt;
&lt;strategy&gt;
&lt;name&gt;org.jooq.util.DefaultGeneratorStrategy&lt;/name&gt;
&lt;/strategy&gt;
#The schema that is used locally as a source for meta information. This could be your
#development schema or the production schema, etc:
generator.database.input-schema=[your database schema / owner / name]
&lt;database&gt;
&lt;!-- The database dialect from jooq-meta. Available dialects are
named org.util.[database].[database]Database. Known values are:
#All elements that are generated from your schema (several Java regular expressions, separated by comma)
#Watch out for case-sensitivity. Depending on your database, this might be important!
#You can create case-insensitive regular expressions using this syntax: (?i:expr)
generator.database.includes=.*
org.jooq.util.ase.ASEDatabase
org.jooq.util.db2.DB2Database
org.jooq.util.derby.DerbyDatabase
org.jooq.util.h2.H2Database
org.jooq.util.hsqldb.HSQLDBDatabase
org.jooq.util.ingres.IngresDatabase
org.jooq.util.mysql.MySQLDatabase
org.jooq.util.oracle.OracleDatabase
org.jooq.util.postgres.PostgresDatabase
org.jooq.util.sqlite.SQLiteDatabaes
org.jooq.util.sqlserver.SQLServerDatabase
org.jooq.util.sybase.SybaseDatabase
#All elements that are excluded from your schema (several Java regular expressions, separated by comma). Excludes match before includes
generator.database.excludes=
You can also provide your own org.jooq.util.Database implementation
here, if your database is currently not supported --&gt;
&lt;name&gt;org.jooq.util.oracle.OracleDatabase&lt;/name&gt;
#Primary key / foreign key relations should be generated and used.
#This will be a prerequisite for various advanced features
#Defaults to false
generator.generate.relations=true
&lt;!-- All elements that are generated from your schema (several Java
regular expressions, separated by comma) Watch out for
case-sensitivity. Depending on your database, this might be
important! You can create case-insensitive regular expressions
using this syntax: (?i:expr)A comma-separated list of regular
expressions --&gt;
&lt;includes&gt;.*&lt;/includes&gt;
#Generate deprecated code for backwards compatibility
#Defaults to true
generator.generate.deprecated=false
&lt;!-- All elements that are excluded from your schema (several Java
regular expressions, separated by comma). Excludes match before
includes --&gt;
&lt;excludes&gt;&lt;/excludes&gt;
#The destination package of your generated classes (within the destination directory)
generator.target.package=[org.jooq.your.package]
&lt;!-- The schema that is used locally as a source for meta information.
This could be your development schema or the production schema, etc
This cannot be combined with the schemata element. --&gt;
&lt;inputSchema&gt;[your database schema / owner / name]&lt;/inputSchema&gt;
&lt;/database&gt;
#The destination directory of your generated classes
generator.target.directory=[/path/to/your/dir]</pre>
&lt;generate&gt;
&lt;!-- See advanced configuration properties --&gt;
&lt;/generate&gt;
<p>And you can add some optional advanced configuration parameters: </p>
<pre class="prettyprint">#The schema that is used in generated source code. This will be the production schema
#Use this to override your local development schema name for source code generation
#If not specified, this will be the same as the input-schema.
generator.database.output-schema=[your database schema / owner / name]
&lt;target&gt;
&lt;!-- The destination package of your generated classes (within the
destination directory) --&gt;
&lt;packageName&gt;[org.jooq.your.packagename]&lt;/packageName&gt;
#Generate java.sql.Timestamp fields for DATE columns. This is particularly useful for Oracle databases
#Defaults to false
generator.database.date-as-timestamp=true
&lt;!-- The destination directory of your generated classes --&gt;
&lt;directory&gt;[/path/to/your/dir]&lt;/directory&gt;
&lt;/target&gt;
&lt;/generator&gt;
&lt;/configuration&gt;</pre>
#Generate instance fields in your tables, as opposed to static fields. This simplifies aliasing
#Defaults to true
generator.generate.instance-fields=true
<p>And you can add some optional advanced configuration parameters for the database: </p>
#Generate the javax.annotation.Generated annotation to indicate jOOQ version used for source code
#generation. Defaults to true
generator.generate.generated-annotation=true
<pre class="prettyprint lang-xml">&lt;!-- These properties can be added to the database element: --&gt;
&lt;database&gt;
&lt;!-- Generate java.sql.Timestamp fields for DATE columns. This is
particularly useful for Oracle databases.
Defaults to false --&gt;
&lt;dateAsTimestamp&gt;false&lt;/dateAsTimestamp&gt;
#Generate jOOU data types for your unsigned data types, which are not natively supported in Java
#Defaults to true
generator.generate.unsigned-types=true
&lt;!-- Generate jOOU data types for your unsigned data types, which are
not natively supported in Java.
Defaults to true --&gt;
&lt;unsignedTypes&gt;true&lt;/unsignedTypes&gt;
#Generate a master data table enum classes (several Java regular expressions, separated by comma)
generator.generate.master-data-tables=[a list of tables]
&lt;!-- The schema that is used in generated source code. This will be the
production schema. Use this to override your local development
schema name for source code generation. If not specified, this
will be the same as the input-schema. --&gt;
&lt;outputSchema&gt;[your database schema / owner / name]&lt;/outputSchema&gt;
&lt;!-- A configuration element to configure several input and/or output
schemata for jooq-meta, in case you're using jooq-meta in a multi-
schema environment.
This cannot be combined with the above inputSchema / outputSchema --&gt;
&lt;schemata&gt;
&lt;schema&gt;
&lt;inputSchema&gt;...&lt;/inputSchema&gt;
&lt;outputSchema&gt;...&lt;/outputSchema&gt;
&lt;/schema&gt;
[ &lt;schema&gt;...&lt;/schema&gt; ... ]
&lt;/schemata&gt;
&lt;!-- A configuration element to configure master data table enum classes --&gt;
&lt;masterDataTables&gt;...&lt;/masterDataTables&gt;
&lt;!-- A configuration element to configure synthetic enum types
This is EXPERIMENTAL functionality. Use at your own risk --&gt;
&lt;enumTypes&gt;...&lt;/enumTypes&gt;
&lt;!-- A configuration element to configure type overrides for generated
artefacts (e.g. in combination with enumTypes)
This is EXPERIMENTAL functionality. Use at your own risk --&gt;
&lt;forcedTypes&gt;...&lt;/forcedTypes&gt;
&lt;/database&gt;</pre>
<p>Also, you can add some optional advanced configuration parameters for the generator: </p>
<pre class="prettyprint lang-xml">&lt;!-- These properties can be added to the generate element: --&gt;
&lt;generate&gt;
&lt;!-- Primary key / foreign key relations should be generated and used.
This is a prerequisite for various advanced features.
Defaults to false --&gt;
&lt;relations&gt;false&lt;/relations&gt;
&lt;!-- Generate navigation methods to navigate foreign key relationships
directly from Record classes. This is only relevant if relations
is set to true, too.
Defaults to true --&gt;
&lt;navigationMethods&gt;true&lt;/navigationMethods&gt;
&lt;!-- Generate deprecated code for backwards compatibility
Defaults to true --&gt;
&lt;deprecated&gt;true&lt;/deprecated&gt;
&lt;!-- Generate instance fields in your tables, as opposed to static
fields. This simplifies aliasing.
Defaults to true --&gt;
&lt;instanceFields&gt;true&lt;/instanceFields&gt;
&lt;!-- Generate the javax.annotation.Generated annotation to indicate
jOOQ version used for source code.
Defaults to true --&gt;
&lt;generatedAnnotation&gt;true&lt;/generatedAnnotation&gt;
&lt;!-- Generate POJOs in addition to Record classes for usage of the
ResultQuery.fetchInto(Class) API
Defaults to false --&gt;
&lt;pojos&gt;false&lt;/pojos&gt;
&lt;!-- Annotate POJOs and Records with JPA annotations for increased
compatibility and better integration with JPA/Hibernate, etc
Defaults to false --&gt;
&lt;jpaAnnotations&gt;false&lt;/jpaAnnotations&gt;
&lt;/generate&gt;</pre>
#For every master data table, specify two special columns
generator.generate.master-data-table-literal.[master data table]=[column used for enum literals]
generator.generate.master-data-table-description.[master data table]=[column used for documentation]</pre>
<p>Check out the manual's section about
<a href="<?=$root?>/manual/ADVANCED/MasterData/" title="jOOQ Manual reference: Master data generation. Enumeration tables">master data</a>
to find out more
about those advanced configuration parameters. </p>
<p>Also, check out the official XSD file at
<a href="http://www.jooq.org/xsd/jooq-codegen-2.0.4.xsd" title="The jOOQ-codegen configuration XSD">http://www.jooq.org/xsd/jooq-codegen-2.0.4.xsd</a>
for a formal specification</p>
<h2>Run jOOQ code generation</h2>
<p>Code generation works by calling this class with the above property file as argument.</p>
<pre class="prettyprint">org.jooq.util.GenerationTool /jooq-config.properties</pre>
<pre class="prettyprint">org.jooq.util.GenerationTool /jooq-config.xml</pre>
<p>Be sure that these elements are located on the classpath: </p>
<ul>
@ -300,13 +397,6 @@ generator.generate.master-data-table-description.[master data table]=[column use
&lt;packageName&gt;org.jooq.util.maven.example&lt;/packageName&gt;
&lt;directory&gt;target/generated-sources/jooq&lt;/directory&gt;
&lt;/target&gt;
&lt;masterDataTables&gt;
&lt;masterDataTable&gt;
&lt;name&gt;t_language&lt;/name&gt;
&lt;literal&gt;cd&lt;/literal&gt;
&lt;description&gt;description&lt;/description&gt;
&lt;/masterDataTable&gt;
&lt;/masterDataTables&gt;
&lt;/generator&gt;
&lt;/configuration&gt;
&lt;/plugin&gt;
@ -315,6 +405,19 @@ generator.generate.master-data-table-description.[master data table]=[column use
<a href="https://github.com/lukaseder/jOOQ/blob/master/jOOQ-codegen-maven-example/pom.xml" title="jOOQ-codegen-maven example pom.xml file">https://github.com/lukaseder/jOOQ/blob/master/jOOQ-codegen-maven-example/pom.xml</a>
</p>
<h3>Migrate properties files from jOOQ 1.7, early versions of jOOQ 2.0.x:</h3>
<p>
Before jOOQ 2.0.4, the code generator was configured using properties files
These files are still supported for source code generation, but their syntax
won't be maintained any longer. If you wish to migrate to XML, you can
migrate the file using this command on the command line
</p>
<pre class="prettyprint">org.jooq.util.GenerationTool /jooq-config.properties migrate</pre>
<p>
Using the migrate flag, jOOQ will read the properties file and output
a corresponding XML file on system out
</p>
<h3>Use jOOQ generated classes in your application</h3>
<p>Be sure, both jOOQ.jar and your generated package (see
configuration) are located on your classpath. Once this is done, you

View File

@ -1001,6 +1001,8 @@ Object[] fetchArray(String fieldName);
<java><![CDATA[// Fetch the resulting records into a custom POJO
// type, which may or may not be JPA-annotated
// Use the generator's <pojos>true</pojos> and <jpaAnnotation>true</jpaAnnotation>
// configurations to generate such POJOs with jOOQ
<E> List<E> fetchInto(Class<? extends E> type);
// Fetch the resulting records into a custom
@ -1410,86 +1412,183 @@ public void bind(BindContext context) throws DataAccessException;</java>
</p>
<h2>Configure jOOQ</h2>
<h2>Configure jOOQ's code generator</h2>
<p>You need to tell jOOQ some things about your database connection.
Here's an example of how to do it for a MySQL database </p>
<config>#Configure the database connection here
jdbc.Driver=com.mysql.jdbc.Driver
jdbc.URL=jdbc:mysql://[your jdbc URL]
jdbc.User=[your database user]
jdbc.Password=[your database password]
Here's an example of how to do it for an Oracle database </p>
<xml><![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration>
<!-- Configure the database connection here -->
<jdbc>
<driver>oracle.jdbc.OracleDriver</driver>
<url>jdbc:oracle:thin:@[your jdbc connection parameters]</url>
<user>[your database user]</user>
<password>[your database password]</password>
</jdbc>
#The default code generator. You can override this one, to generate your own code style
#Defaults to org.jooq.util.DefaultGenerator
generator=org.jooq.util.DefaultGenerator
<generator>
<!-- The default code generator. You can override this one, to generate your own code style
Defaults to org.jooq.util.DefaultGenerator -->
<name>org.jooq.util.DefaultGenerator</name>
#The database type. The format here is:
#generator.database=org.util.[database].[database]Database
generator.database=org.jooq.util.mysql.MySQLDatabase
<!-- The naming strategy used for class and field names.
You may override this with your custom naming strategy.
Defaults to org.jooq.util.DefaultGeneratorStrategy -->
<strategy>
<name>org.jooq.util.DefaultGeneratorStrategy</name>
</strategy>
#The schema that is used locally as a source for meta information. This could be your
#development schema or the production schema, etc:
generator.database.input-schema=[your database schema / owner / name]
<database>
<!-- The database dialect from jooq-meta. Available dialects are
named org.util.[database].[database]Database. Known values are:
#All elements that are generated from your schema (several Java regular expressions, separated by comma)
#Watch out for case-sensitivity. Depending on your database, this might be important!
#You can create case-insensitive regular expressions using this syntax: (?i:expr)
generator.database.includes=.*
org.jooq.util.ase.ASEDatabase
org.jooq.util.db2.DB2Database
org.jooq.util.derby.DerbyDatabase
org.jooq.util.h2.H2Database
org.jooq.util.hsqldb.HSQLDBDatabase
org.jooq.util.ingres.IngresDatabase
org.jooq.util.mysql.MySQLDatabase
org.jooq.util.oracle.OracleDatabase
org.jooq.util.postgres.PostgresDatabase
org.jooq.util.sqlite.SQLiteDatabaes
org.jooq.util.sqlserver.SQLServerDatabase
org.jooq.util.sybase.SybaseDatabase
#All elements that are excluded from your schema (several Java regular expressions, separated by comma). Excludes match before includes
generator.database.excludes=
You can also provide your own org.jooq.util.Database implementation
here, if your database is currently not supported -->
<name>org.jooq.util.oracle.OracleDatabase</name>
#Primary key / foreign key relations should be generated and used.
#This will be a prerequisite for various advanced features
#Defaults to false
generator.generate.relations=true
<!-- All elements that are generated from your schema (several Java
regular expressions, separated by comma) Watch out for
case-sensitivity. Depending on your database, this might be
important! You can create case-insensitive regular expressions
using this syntax: (?i:expr)A comma-separated list of regular
expressions -->
<includes>.*</includes>
#Generate deprecated code for backwards compatibility
#Defaults to true
generator.generate.deprecated=false
<!-- All elements that are excluded from your schema (several Java
regular expressions, separated by comma). Excludes match before
includes -->
<excludes></excludes>
#The destination package of your generated classes (within the destination directory)
generator.target.package=[org.jooq.your.package]
<!-- The schema that is used locally as a source for meta information.
This could be your development schema or the production schema, etc
This cannot be combined with the schemata element. -->
<inputSchema>[your database schema / owner / name]</inputSchema>
</database>
#The destination directory of your generated classes
generator.target.directory=[/path/to/your/dir]</config>
<generate>
<!-- See advanced configuration properties -->
</generate>
<p>And you can add some optional advanced configuration parameters: </p>
<config>#The schema that is used in generated source code. This will be the production schema
#Use this to override your local development schema name for source code generation
#If not specified, this will be the same as the input-schema.
generator.database.output-schema=[your database schema / owner / name]
<target>
<!-- The destination package of your generated classes (within the
destination directory) -->
<packageName>[org.jooq.your.packagename]</packageName>
#Generate java.sql.Timestamp fields for DATE columns. This is particularly useful for Oracle databases
#Defaults to false
generator.database.date-as-timestamp=true
<!-- The destination directory of your generated classes -->
<directory>[/path/to/your/dir]</directory>
</target>
</generator>
</configuration>]]></xml>
#Generate instance fields in your tables, as opposed to static fields. This simplifies aliasing
#Defaults to true
generator.generate.instance-fields=true
<p>And you can add some optional advanced configuration parameters for the database: </p>
#Generate the javax.annotation.Generated annotation to indicate jOOQ version used for source code
#generation. Defaults to true
generator.generate.generated-annotation=true
<xml><![CDATA[<!-- These properties can be added to the database element: -->
<database>
<!-- Generate java.sql.Timestamp fields for DATE columns. This is
particularly useful for Oracle databases.
Defaults to false -->
<dateAsTimestamp>false</dateAsTimestamp>
#Generate jOOU data types for your unsigned data types, which are not natively supported in Java
#Defaults to true
generator.generate.unsigned-types=true
<!-- Generate jOOU data types for your unsigned data types, which are
not natively supported in Java.
Defaults to true -->
<unsignedTypes>true</unsignedTypes>
#Generate a master data table enum classes (several Java regular expressions, separated by comma)
generator.generate.master-data-tables=[a list of tables]
<!-- The schema that is used in generated source code. This will be the
production schema. Use this to override your local development
schema name for source code generation. If not specified, this
will be the same as the input-schema. -->
<outputSchema>[your database schema / owner / name]</outputSchema>
<!-- A configuration element to configure several input and/or output
schemata for jooq-meta, in case you're using jooq-meta in a multi-
schema environment.
This cannot be combined with the above inputSchema / outputSchema -->
<schemata>
<schema>
<inputSchema>...</inputSchema>
<outputSchema>...</outputSchema>
</schema>
[ <schema>...</schema> ... ]
</schemata>
<!-- A configuration element to configure master data table enum classes -->
<masterDataTables>...</masterDataTables>
<!-- A configuration element to configure synthetic enum types
This is EXPERIMENTAL functionality. Use at your own risk -->
<enumTypes>...</enumTypes>
<!-- A configuration element to configure type overrides for generated
artefacts (e.g. in combination with enumTypes)
This is EXPERIMENTAL functionality. Use at your own risk -->
<forcedTypes>...</forcedTypes>
</database>]]></xml>
<p>Also, you can add some optional advanced configuration parameters for the generator: </p>
<xml><![CDATA[<!-- These properties can be added to the generate element: -->
<generate>
<!-- Primary key / foreign key relations should be generated and used.
This is a prerequisite for various advanced features.
Defaults to false -->
<relations>false</relations>
<!-- Generate navigation methods to navigate foreign key relationships
directly from Record classes. This is only relevant if relations
is set to true, too.
Defaults to true -->
<navigationMethods>true</navigationMethods>
<!-- Generate deprecated code for backwards compatibility
Defaults to true -->
<deprecated>true</deprecated>
<!-- Generate instance fields in your tables, as opposed to static
fields. This simplifies aliasing.
Defaults to true -->
<instanceFields>true</instanceFields>
<!-- Generate the javax.annotation.Generated annotation to indicate
jOOQ version used for source code.
Defaults to true -->
<generatedAnnotation>true</generatedAnnotation>
<!-- Generate POJOs in addition to Record classes for usage of the
ResultQuery.fetchInto(Class) API
Defaults to false -->
<pojos>false</pojos>
<!-- Annotate POJOs and Records with JPA annotations for increased
compatibility and better integration with JPA/Hibernate, etc
Defaults to false -->
<jpaAnnotations>false</jpaAnnotations>
</generate>]]></xml>
#For every master data table, specify two special columns
generator.generate.master-data-table-literal.[master data table]=[column used for enum literals]
generator.generate.master-data-table-description.[master data table]=[column used for documentation]</config>
<p>Check out the manual's section about
<reference id="MasterData" title="master data"/>
to find out more
about those advanced configuration parameters. </p>
<p>Also, check out the official XSD file at
<a href="http://www.jooq.org/xsd/jooq-codegen-2.0.4.xsd" title="The jOOQ-codegen configuration XSD">http://www.jooq.org/xsd/jooq-codegen-2.0.4.xsd</a>
for a formal specification</p>
<h2>Run jOOQ code generation</h2>
<p>Code generation works by calling this class with the above property file as argument.</p>
<config>org.jooq.util.GenerationTool /jooq-config.properties</config>
<config>org.jooq.util.GenerationTool /jooq-config.xml</config>
<p>Be sure that these elements are located on the classpath: </p>
<ul>
<li>The property file</li>
@ -1626,13 +1725,6 @@ generator.generate.master-data-table-description.[master data table]=[column use
<packageName>org.jooq.util.maven.example</packageName>
<directory>target/generated-sources/jooq</directory>
</target>
<masterDataTables>
<masterDataTable>
<name>t_language</name>
<literal>cd</literal>
<description>description</description>
</masterDataTable>
</masterDataTables>
</generator>
</configuration>
</plugin>
@ -1640,6 +1732,19 @@ generator.generate.master-data-table-description.[master data table]=[column use
<p>See the full example of a pom.xml including the jOOQ-codegen artefact here:
<a href="https://github.com/lukaseder/jOOQ/blob/master/jOOQ-codegen-maven-example/pom.xml" title="jOOQ-codegen-maven example pom.xml file">https://github.com/lukaseder/jOOQ/blob/master/jOOQ-codegen-maven-example/pom.xml</a></p>
<h3>Migrate properties files from jOOQ 1.7, early versions of jOOQ 2.0.x:</h3>
<p>
Before jOOQ 2.0.4, the code generator was configured using properties files
These files are still supported for source code generation, but their syntax
won't be maintained any longer. If you wish to migrate to XML, you can
migrate the file using this command on the command line
</p>
<config>org.jooq.util.GenerationTool /jooq-config.properties migrate</config>
<p>
Using the migrate flag, jOOQ will read the properties file and output
a corresponding XML file on system out
</p>
<h3>Use jOOQ generated classes in your application</h3>
<p>Be sure, both jOOQ.jar and your generated package (see
configuration) are located on your classpath. Once this is done, you
@ -3705,12 +3810,23 @@ create.select(LAST_NAME, COUNT1, COUNT2)
<p>As previously discussed in the
<reference id="Configuration" title="configuration and setup"/>
section, you can configure master data tables as follows: </p>
<config>#Generate a master data table enum classes (several Java regular expressions, separated by comma)
generator.generate.master-data-tables=[a list of tables]
<xml><![CDATA[<!-- These properties can be added to the database element: -->
<database>
<masterDataTables>
<masterDataTable>
<!-- The name of a master data table -->
<name>[a table name]</name>
#For every master data table, specify two special columns
generator.generate.master-data-table-literal.[master data table]=[column used for enum literals]
generator.generate.master-data-table-description.[master data table]=[column used for documentation]</config>
<!-- The column used for enum literals -->
<literal>[a column name]</literal>
<!-- The column used for documentation -->
<description>[a column name]</description>
</masterDataTable>
[ <masterDataTable>...</masterDataTable> ... ]
</masterDataTables>
</database>]]></xml>
<p>The results of this will be a Java enum that looks similar to this: </p>
<java><![CDATA[public enum TLanguage implements MasterDataType<Integer> {