Release 2.0.5 - Updated manual

This commit is contained in:
Lukas Eder 2012-02-26 20:52:56 +00:00
parent c1cabd9937
commit fa1b5fae03
18 changed files with 1548 additions and 538 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

View File

@ -24,6 +24,10 @@ features for the jOOQ Factory. This configuration now includes:
execute java.sql.PreparedStatements (with bind variables) or
static java.sql.Statements with inlined variables.
The runtime configuration is documented here:
http://www.jooq.org/manual/JOOQ/Factory/
The listener and tracing support has been requested by
Christopher Deckers, a new jOOQ user who has had the courtesy to
contribute the new jOOQ Console, which is documented here:

View File

@ -369,6 +369,22 @@
<fo:block font-size="11pt" page-break-inside="avoid">
<fo:block text-align-last="justify">
<fo:inline>
<fo:basic-link internal-destination="AdvancedConfiguration">Advanced configuration of the generator<fo:leader leader-pattern="dots"/>
<fo:page-number-citation ref-id="AdvancedConfiguration"/>
</fo:basic-link>
</fo:inline>
</fo:block>
</fo:block>
</fo:list-item-body>
</fo:list-item>
<fo:list-item>
<fo:list-item-label>
<fo:block font-size="11pt" page-break-inside="avoid">3.</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block font-size="11pt" page-break-inside="avoid">
<fo:block text-align-last="justify">
<fo:inline>
<fo:basic-link internal-destination="SCHEMA">The schema, top-level generated artefact<fo:leader leader-pattern="dots"/>
<fo:page-number-citation ref-id="SCHEMA"/>
</fo:basic-link>
@ -379,7 +395,7 @@
</fo:list-item>
<fo:list-item>
<fo:list-item-label>
<fo:block font-size="11pt" page-break-inside="avoid">3.</fo:block>
<fo:block font-size="11pt" page-break-inside="avoid">4.</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block font-size="11pt" page-break-inside="avoid">
@ -395,7 +411,7 @@
</fo:list-item>
<fo:list-item>
<fo:list-item-label>
<fo:block font-size="11pt" page-break-inside="avoid">4.</fo:block>
<fo:block font-size="11pt" page-break-inside="avoid">5.</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block font-size="11pt" page-break-inside="avoid">
@ -411,7 +427,7 @@
</fo:list-item>
<fo:list-item>
<fo:list-item-label>
<fo:block font-size="11pt" page-break-inside="avoid">5.</fo:block>
<fo:block font-size="11pt" page-break-inside="avoid">6.</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block font-size="11pt" page-break-inside="avoid">
@ -427,7 +443,7 @@
</fo:list-item>
<fo:list-item>
<fo:list-item-label>
<fo:block font-size="11pt" page-break-inside="avoid">6.</fo:block>
<fo:block font-size="11pt" page-break-inside="avoid">7.</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block font-size="11pt" page-break-inside="avoid">
@ -745,6 +761,22 @@
<fo:block font-size="11pt" page-break-inside="avoid">
<fo:block text-align-last="justify">
<fo:inline>
<fo:basic-link internal-destination="ExecuteListener">Execute listeners and SQL tracing<fo:leader leader-pattern="dots"/>
<fo:page-number-citation ref-id="ExecuteListener"/>
</fo:basic-link>
</fo:inline>
</fo:block>
</fo:block>
</fo:list-item-body>
</fo:list-item>
<fo:list-item>
<fo:list-item-label>
<fo:block font-size="11pt" page-break-inside="avoid">4.</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block font-size="11pt" page-break-inside="avoid">
<fo:block text-align-last="justify">
<fo:inline>
<fo:basic-link internal-destination="OracleHints">Adding Oracle hints to queries<fo:leader leader-pattern="dots"/>
<fo:page-number-citation ref-id="OracleHints"/>
</fo:basic-link>
@ -755,7 +787,7 @@
</fo:list-item>
<fo:list-item>
<fo:list-item-label>
<fo:block font-size="11pt" page-break-inside="avoid">4.</fo:block>
<fo:block font-size="11pt" page-break-inside="avoid">5.</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block font-size="11pt" page-break-inside="avoid">
@ -771,7 +803,7 @@
</fo:list-item>
<fo:list-item>
<fo:list-item-label>
<fo:block font-size="11pt" page-break-inside="avoid">5.</fo:block>
<fo:block font-size="11pt" page-break-inside="avoid">6.</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block font-size="11pt" page-break-inside="avoid">
@ -787,7 +819,7 @@
</fo:list-item>
<fo:list-item>
<fo:list-item-label>
<fo:block font-size="11pt" page-break-inside="avoid">6.</fo:block>
<fo:block font-size="11pt" page-break-inside="avoid">7.</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block font-size="11pt" page-break-inside="avoid">
@ -803,7 +835,7 @@
</fo:list-item>
<fo:list-item>
<fo:list-item-label>
<fo:block font-size="11pt" page-break-inside="avoid">7.</fo:block>
<fo:block font-size="11pt" page-break-inside="avoid">8.</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block font-size="11pt" page-break-inside="avoid">
@ -819,7 +851,7 @@
</fo:list-item>
<fo:list-item>
<fo:list-item-label>
<fo:block font-size="11pt" page-break-inside="avoid">8.</fo:block>
<fo:block font-size="11pt" page-break-inside="avoid">9.</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block font-size="11pt" page-break-inside="avoid">
@ -1019,10 +1051,8 @@ CREATE TABLE t_book_to_book_store (
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block font-size="11pt" page-break-inside="avoid">
<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/src/main/java/org/jooq/SchemaMapping.java')">org.jooq.SchemaMapping</fo:basic-link> :
An optional mapping of schemata. Check out the
<fo:basic-link font-size="11pt" color="#882222" font-weight="bold" text-shadow="0 1px 2px #666666" internal-destination="SchemaMapping">SchemaMapping</fo:basic-link>
page for details</fo:block>
<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/src/main/java/org/jooq/conf/Settings.java')">org.jooq.conf.Settings</fo:basic-link> :
An optional runtime configuration.</fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
@ -1031,6 +1061,42 @@ CREATE TABLE t_book_to_book_store (
several distinct JDBC Connections in your software, this will mean
that you have to create a new Factory every time. </fo:block>
<fo:block font-family="Georgia" font-size="16pt" padding-top="10pt" padding-bottom="10pt" page-break-after="avoid">Factory settings</fo:block>
<fo:block font-size="11pt">
The jOOQ Factory allows for some optional configuration elements to be used by advanced users.
The <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/src/main/java/org/jooq/conf/Settings.java')">Settings</fo:basic-link> class is a JAXB-annotated
type. In future releases of jOOQ, these settings can be loaded from an XML file automatically.
Subsequent sections of the manual contain some more in-depth explanations about these settings:
</fo:block>
<fo:block padding-top="16pt" padding-bottom="16pt" page-break-inside="avoid">
<fo:list-block>
<fo:list-item>
<fo:list-item-label>
<fo:block font-size="11pt" page-break-inside="avoid">-</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block font-size="11pt" page-break-inside="avoid">
<fo:basic-link font-size="11pt" color="#882222" font-weight="bold" text-shadow="0 1px 2px #666666" internal-destination="SchemaMapping">Runtime schema and table mapping</fo:basic-link>
</fo:block>
</fo:list-item-body>
</fo:list-item>
<fo:list-item>
<fo:list-item-label>
<fo:block font-size="11pt" page-break-inside="avoid">-</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block font-size="11pt" page-break-inside="avoid">
<fo:basic-link font-size="11pt" color="#882222" font-weight="bold" text-shadow="0 1px 2px #666666" internal-destination="ExecuteListener">Execute listeners and SQL tracing</fo:basic-link>
</fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
</fo:block>
<fo:block font-size="11pt">
Please refer to the jOOQ runtime configuration XSD for more details:<fo:block/>
<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-runtime-2.0.5.xsd')">http://www.jooq.org/xsd/jooq-runtime-2.0.5.xsd</fo:basic-link>
</fo:block>
<fo:block font-family="Georgia" font-size="16pt" padding-top="10pt" padding-bottom="10pt" page-break-after="avoid">Factory subclasses</fo:block>
<fo:block font-size="11pt">
There are a couple of subclasses for the general Factory. Each SQL
@ -2095,6 +2161,9 @@ Object[] fetchArray(String fieldName);
// Fetch a Cursor for lazy iteration
Cursor<R> fetchLazy();
// Or a JDBC ResultSet, if you prefer that
ResultSet fetchResultSet();
// Fetch data asynchronously and let client code
// decide, when the data must be available.
// This makes use of the java.util.concurrent API,
@ -2574,17 +2643,6 @@ public void bind(BindContext context) throws DataAccessException;</fo:block>
</jdbc>
<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 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>
<database>
<!-- The database dialect from jooq-meta. Available dialects are
named org.util.[database].[database]Database. Known values are:
@ -2640,97 +2698,10 @@ public void bind(BindContext context) throws DataAccessException;</fo:block>
</generator>
</configuration>]]></fo:block>
<fo:block font-size="11pt">And you can add some optional advanced configuration parameters for the 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[<!-- 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 -->
<unsignedTypes>true</unsignedTypes>
<!-- 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>
<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:block font-size="11pt">
There are also lots of advanced configuration parameters, which will be
treated in the <fo:basic-link font-size="11pt" color="#882222" font-weight="bold" text-shadow="0 1px 2px #666666" internal-destination="AdvancedConfiguration">manual's next section</fo:basic-link>
Note, you can find 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>
@ -2954,10 +2925,215 @@ public void bind(BindContext context) throws DataAccessException;</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
can execute SQL statements with your generated classes.</fo:block>
<fo:block font-family="Georgia" font-size="18pt" padding-top="12pt" padding-bottom="12pt" page-break-after="avoid" id="AdvancedConfiguration">
<fo:marker marker-class-name="section">
<fo:block>2.2. Advanced configuration of the generator</fo:block>
</fo:marker>2.2. Advanced configuration of the generator</fo:block>
<fo:block font-size="11pt">jOOQ power users may want to fine-tune their source code generation settings. Here's how to do this</fo:block>
<fo:block font-family="Georgia" font-size="16pt" padding-top="10pt" padding-bottom="10pt" page-break-after="avoid">Code generation</fo:block>
<fo:block font-size="11pt">
In the <fo:basic-link font-size="11pt" color="#882222" font-weight="bold" text-shadow="0 1px 2px #666666" internal-destination="Configuration">previous section</fo:basic-link>
we have seen how jOOQ's source code generator is configured and
run within a few steps. In this chapter we'll treat some advanced
settings
</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 directly to the generator element: -->
<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 naming strategy used for class and field names.
You may override this with your custom naming strategy. Some examples follow
Defaults to org.jooq.util.DefaultGeneratorStrategy -->
<strategy>
<name>org.jooq.util.DefaultGeneratorStrategy</name>
</strategy>
</generator>]]></fo:block>
<fo:block font-size="11pt">
The following example shows how you can override the
DefaultGeneratorStrategy to render table and column names the way
they are defined in the database, rather than switching them to
camel case:
</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">/**
* It is recommended that you extend the DefaultGeneratorStrategy. Most of the
* GeneratorStrategy API is already declared final. You only need to override any
* of the following methods, for whatever generation behaviour you'd like to achieve
*
* Beware that most methods also receive a "Mode" object, to tell you whether a
* TableDefinition is being rendered as a Table, Record, POJO, etc. Depending on
* that information, you can add a suffix only for TableRecords, not for Tables
*/
public class AsInDatabaseStrategy extends DefaultGeneratorStrategy {
/**
* Override this to specifiy what identifiers in Java should look like.
* This will just take the identifier as defined in the database.
*/
@Override
public String getJavaIdentifier(Definition definition) {
return definition.getOutputName();
}
/**
* Override these to specify what a setter in Java should look like. Setters
* are used in TableRecords, UDTRecords, and POJOs. This example will name
* setters "set[NAME_IN_DATABASE]"
*/
@Override
public String getJavaSetterName(Definition definition, Mode mode) {
return "set" + definition.getOutputName();
}
/**
* Just like setters...
*/
@Override
public String getJavaGetterName(Definition definition, Mode mode) {
return "get" + definition.getOutputName();
}
/**
* Override this method to define what a Java method generated from a database
* Definition should look like. This is used mostly for convenience methods
* when calling stored procedures and functions. This example shows how to
* set a prefix to a CamelCase version of your procedure
*/
@Override
public String getJavaMethodName(Definition definition, Mode mode) {
return "call" + org.jooq.tools.StringUtils.toCamelCase(definition.getOutputName());
}
/**
* Override this method to define how your Java classes and Java files should
* be named. This example applies no custom setting and uses CamelCase versions
* instead
*/
@Override
public String getJavaClassName(Definition definition, Mode mode) {
return super.getJavaClassName(definition, mode);
}
/**
* Override this method to re-define the package names of your generated
* artefacts.
*/
@Override
public String getJavaPackageName(Definition definition, Mode mode) {
return super.getJavaPackageName(definition, mode);
}
/**
* Override this method to define how Java members should be named. This is
* used for POJOs and method arguments
*/
@Override
public String getJavaMemberName(Definition definition, Mode mode) {
return definition.getOutputName();
}
}</fo:block>
<fo:block font-size="11pt">
Within the &lt;generator/&gt; element, there are other configuration elements:
</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 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 -->
<unsignedTypes>true</unsignedTypes>
<!-- 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>
<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-family="Georgia" font-size="18pt" padding-top="12pt" padding-bottom="12pt" page-break-after="avoid" id="SCHEMA">
<fo:marker marker-class-name="section">
<fo:block>2.2. The schema, top-level generated artefact</fo:block>
</fo:marker>2.2. The schema, top-level generated artefact</fo:block>
<fo:block>2.3. The schema, top-level generated artefact</fo:block>
</fo:marker>2.3. The schema, top-level generated artefact</fo:block>
<fo:block font-size="11pt">The schema is the top-level generated object in jOOQ. In many
RDBMS, the schema coincides with the owner of tables and other objects
</fo:block>
@ -2993,8 +3169,8 @@ public void bind(BindContext context) throws DataAccessException;</fo:block>
public final java.util.List&lt;org.jooq.Table&lt;?&gt;&gt; getTables();</fo:block>
<fo:block font-family="Georgia" font-size="18pt" padding-top="12pt" padding-bottom="12pt" page-break-after="avoid" id="TABLE">
<fo:marker marker-class-name="section">
<fo:block>2.3. Tables, views and their corresponding records</fo:block>
</fo:marker>2.3. Tables, views and their corresponding records</fo:block>
<fo:block>2.4. Tables, views and their corresponding records</fo:block>
</fo:marker>2.4. Tables, views and their corresponding records</fo:block>
<fo:block font-size="11pt">
The most important generated artefacts are Tables and TableRecords.
Every Table has a Record type associated with it that models a single tuple
@ -3067,8 +3243,8 @@ public final java.util.List&lt;org.jooq.Table&lt;?&gt;&gt; getTables();</fo:bloc
}</fo:block>
<fo:block font-family="Georgia" font-size="18pt" padding-top="12pt" padding-bottom="12pt" page-break-after="avoid" id="PROCEDURE">
<fo:marker marker-class-name="section">
<fo:block>2.4. Procedures and packages</fo:block>
</fo:marker>2.4. Procedures and packages</fo:block>
<fo:block>2.5. Procedures and packages</fo:block>
</fo:marker>2.5. Procedures and packages</fo:block>
<fo:block font-size="11pt">
Procedure support is one of the most important reasons why you should consider
jOOQ. jOOQ heavily facilitates the use of stored procedures and
@ -3293,8 +3469,8 @@ assertNotNull(author.getLastName());</fo:block>
<fo:block font-family="Georgia" font-size="18pt" padding-top="12pt" padding-bottom="12pt" page-break-after="avoid" id="UDT">
<fo:marker marker-class-name="section">
<fo:block>2.5. UDT's including ARRAY and ENUM types</fo:block>
</fo:marker>2.5. UDT's including ARRAY and ENUM types</fo:block>
<fo:block>2.6. UDT's including ARRAY and ENUM types</fo:block>
</fo:marker>2.6. UDT's including ARRAY and ENUM types</fo:block>
<fo:block font-size="11pt">
Databases become more powerful when you can structure your data in user
defined types. It's time for Java developers to give some credit to
@ -3678,8 +3854,8 @@ public class TBookRecord extends UpdatableRecordImpl&lt;TBookRecord&gt; {
details. </fo:block>
<fo:block font-family="Georgia" font-size="18pt" padding-top="12pt" padding-bottom="12pt" page-break-after="avoid" id="SEQUENCE">
<fo:marker marker-class-name="section">
<fo:block>2.6. Sequences</fo:block>
</fo:marker>2.6. Sequences</fo:block>
<fo:block>2.7. Sequences</fo:block>
</fo:marker>2.7. Sequences</fo:block>
<fo:block font-size="11pt">
jOOQ also generates convenience artefacts for sequences, where this is
supported: DB2, Derby, H2, HSQLDB, Oracle, Postgres, and more.
@ -4156,6 +4332,8 @@ TableOnConditionStep onKey(ForeignKey<?, ?> key);]]></fo:block>
Condition notIn(Select<?> query);
Condition in(Collection<T> values);
Condition between(T minValue, T maxValue);
Condition contains(T value);
Condition contains(Field<T> value);
Condition equal(T value);
Condition equal(Field<T> field);
Condition equal(Select<?> query);
@ -4165,6 +4343,8 @@ TableOnConditionStep onKey(ForeignKey<?, ?> key);]]></fo:block>
Condition equalAll(Select<?> query);
Condition equalAll(T... array);
Condition equalAll(Field<T[]> array);
Condition equalIgnoreCase(String value);
Condition equalIgnoreCase(Field<String> value);
Condition notEqual(T value);
Condition notEqual(Field<T> field);
Condition notEqual(Select<?> query);
@ -5599,15 +5779,18 @@ create.select(LAST_NAME, COUNT1, COUNT2)
<fo:block font-size="11pt">When a user from My Book World logs in, you want them to access the
MY_BOOK_WORLD schema using classes generated from DEV. This can be
achieved with the
<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/src/main/java/org/jooq/SchemaMapping.java')">org.jooq.SchemaMapping</fo:basic-link>
class, that you can equip your Factory
<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/src/main/java/org/jooq/conf/RenderMapping.java')">org.jooq.conf.RenderMapping</fo:basic-link>
class, that you can equip your Factory's settings
with. Take the following example: </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">SchemaMapping mapping = new SchemaMapping();
mapping.add(DEV, "MY_BOOK_WORLD");
<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">Settings settings = new Settings()
.withRenderMapping(new RenderMapping()
.withSchemata(
new MappedSchema().withInput("DEV")
.withOutput("MY_BOOK_WORLD")));
// Add the mapping to the factory
Factory create = new Factory(connection, SQLDialect.ORACLE, mapping);
// Add the settings to the factory
Factory create = new Factory(connection, SQLDialect.ORACLE, settings);
// Run queries with the "mapped" factory
create.selectFrom(T_AUTHOR).fetch();</fo:block>
@ -5621,12 +5804,27 @@ create.selectFrom(T_AUTHOR).fetch();</fo:block>
<fo:block font-size="11pt">Your development database may not be restricted to hold only one DEV
schema. You may also have a LOG schema and a MASTER schema. Let's say
the MASTER schema is shared among all customers, but each customer has
their own LOG schema instance. Then you can enhance your SchemaMapping
like this: </fo:block>
their own LOG schema instance. Then you can enhance your RenderMapping
like this (e.g. using an XML configuration file): </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">SchemaMapping mapping = new SchemaMapping();
mapping.add(DEV, "MY_BOOK_WORLD");
mapping.add(LOG, "MY_BOOK_WORLD_LOG");</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[<settings xmlns="http://www.jooq.org/xsd/jooq-runtime-2.0.5.xsd">
<renderMapping>
<schemata>
<schema>
<input>DEV</input>
<output>MY_BOOK_WORLD</output>
</schema>
<schema>
<input>LOG</input>
<output>MY_BOOK_WORLD_LOG</output>
</schema>
</schemata>
</renderMapping>
</settings>]]></fo:block>
<fo:block font-size="11pt">Note, you can load the above XML file like 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">Settings settings = JAXB.unmarshal(new File("jooq-runtime.xml"), Settings.class);</fo:block>
<fo:block font-size="11pt">This will map generated classes from DEV to MY_BOOK_WORLD, from LOG
to MY_BOOK_WORLD_LOG, but leave the MASTER schema alone. Whenever you
@ -5660,12 +5858,17 @@ SELECT * FROM T_AUTHOR</fo:block>
applied to all of your tables. This can be achieved by creating the
following mapping: </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">SchemaMapping mapping = new SchemaMapping();
mapping.add(DEV, "MY_BOOK_WORLD");
mapping.add(T_AUTHOR, "MY_APP__T_AUTHOR");
<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">Settings settings = new Settings()
.withRenderMapping(new RenderMapping()
.withSchemata(
new MappedSchema().withInput("DEV")
.withOutput("MY_BOOK_WORLD")
.withTables(
new MappedTable().withInput("T_AUTHOR")
.withOutput("MY_APP__T_AUTHOR"))));
// Add the mapping to the factory
Factory create = new Factory(connection, SQLDialect.ORACLE, mapping);
// Add the settings to the factory
Factory create = new Factory(connection, SQLDialect.ORACLE, settings);
// Run queries with the "mapped" factory
create.selectFrom(T_AUTHOR).fetch();</fo:block>
@ -5694,10 +5897,73 @@ create.selectFrom(T_AUTHOR).fetch();</fo:block>
<fo:basic-link font-size="11pt" color="#882222" font-weight="bold" text-shadow="0 1px 2px #666666" internal-destination="META">jooq-codegen configuration</fo:basic-link>
for more details
</fo:block>
<fo:block font-family="Georgia" font-size="18pt" padding-top="12pt" padding-bottom="12pt" page-break-after="avoid" id="ExecuteListener">
<fo:marker marker-class-name="section">
<fo:block>4.3. Execute listeners and SQL tracing</fo:block>
</fo:marker>4.3. Execute listeners and SQL tracing</fo:block>
<fo:block font-size="11pt">
Feel the heart beat of your SQL statements at a very low level using listeners
</fo:block>
<fo:block font-family="Georgia" font-size="16pt" padding-top="10pt" padding-bottom="10pt" page-break-after="avoid">ExecuteListener</fo:block>
<fo:block font-size="11pt">
The <fo:basic-link font-size="11pt" color="#882222" font-weight="bold" text-shadow="0 1px 2px #666666" internal-destination="Factory">jOOQ Factory Settings</fo:basic-link>
let you specify a list of <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/src/main/java/org/jooq/ExecuteListener.java')">org.jooq.ExecuteListener</fo:basic-link> classes.
The ExecuteListener is essentially an event listener for
Query, Routine, or ResultSet render, prepare, bind, execute, fetch steps. It is a
base type for loggers, debuggers, profilers, data collectors. Advanced ExecuteListeners
can also provide custom implementations of Connection, PreparedStatement and ResultSet
to jOOQ in apropriate methods. For convenience, consider extending
<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/src/main/java/org/jooq/impl/DefaultExecuteListener.java')">org.jooq.impl.DefaultExecuteListener</fo:basic-link>
instead of implementing this interface. Please read the
<fo:basic-link font-size="11pt" color="#882222" font-weight="bold" text-shadow="0 1px 2px #666666" external-destination="url('www.jooq.org/javadoc/latest/org/jooq/ExecuteListener.html')">ExecuteListener Javadoc</fo:basic-link>
for more details
</fo:block>
<fo:block font-family="Georgia" font-size="16pt" padding-top="10pt" padding-bottom="10pt" page-break-after="avoid">jOOQ Console</fo:block>
<fo:block font-size="11pt">
The ExecuteListener API was driven by a feature request by Christopher Deckers, who has
had the courtesy to contribute the jOOQ Console, a sample application interfacing
with jOOQ's ExecuteListeners. Please note that the jOOQ Console is still experimental.
Any feedback is very welcome on
<fo:basic-link font-size="11pt" color="#882222" font-weight="bold" text-shadow="0 1px 2px #666666" external-destination="url('http://groups.google.com/group/jooq-user')">the jooq-user group</fo:basic-link>
</fo:block>
<fo:block font-size="11pt">
Here are the steps you need to do to run the console
</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">// Create a new RemoteDebuggerServer in your application that listens to
// incoming connections on a given port
SERVER = new RemoteDebuggerServer(DEBUGGER_PORT);</fo:block>
<fo:block font-size="11pt">
And configure the <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/src/main/java/org/jooq/debug/DebugListener.java')">org.jooq.debug.DebugListener</fo:basic-link> in the
Factory's settings:
</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[<settings>
<executeListeners>
<executeListener>org.jooq.debug.DebugListener</executeListener>
</executeListeners>
</settings>]]></fo:block>
<fo:block font-size="11pt">
Now start your application and the
<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/src/main/java/org/jooq/debug/console/Console.java')">org.jooq.debug.console.Console</fo:basic-link>, and start profiling!
</fo:block>
<fo:block font-size="11pt">
<fo:block text-align="center">
<fo:external-graphic padding-top="10pt" padding-bottom="10pt" src="url('C:/Users/lukas/workspace/jOOQ-website/img/jooq-console-01.png')"/>
</fo:block>
</fo:block>
<fo:block font-size="11pt">
The jOOQ Console also has other modes of execution, which will be documented here
soon.
</fo:block>
<fo:block font-family="Georgia" font-size="18pt" padding-top="12pt" padding-bottom="12pt" page-break-after="avoid" id="OracleHints">
<fo:marker marker-class-name="section">
<fo:block>4.3. Adding Oracle hints to queries</fo:block>
</fo:marker>4.3. Adding Oracle hints to queries</fo:block>
<fo:block>4.4. Adding Oracle hints to queries</fo:block>
</fo:marker>4.4. Adding Oracle hints to queries</fo:block>
<fo:block font-size="11pt">
Oracle has a powerful syntax to add hints as comments directly in your SQL
</fo:block>
@ -5718,8 +5984,8 @@ create.selectFrom(T_AUTHOR).fetch();</fo:block>
SELECT [DISTINCT] keywords and the actual projection list </fo:block>
<fo:block font-family="Georgia" font-size="18pt" padding-top="12pt" padding-bottom="12pt" page-break-after="avoid" id="CONNECTBY">
<fo:marker marker-class-name="section">
<fo:block>4.4. The Oracle CONNECT BY clause</fo:block>
</fo:marker>4.4. The Oracle CONNECT BY clause</fo:block>
<fo:block>4.5. The Oracle CONNECT BY clause</fo:block>
</fo:marker>4.5. The Oracle CONNECT BY clause</fo:block>
<fo:block font-size="11pt">
Hierarchical queries are supported by many RDBMS using the WITH clause.
Oracle has a very neat and much less verbose syntax for hierarchical
@ -5772,8 +6038,8 @@ create.select(create.rownum())
</fo:block>
<fo:block font-family="Georgia" font-size="18pt" padding-top="12pt" padding-bottom="12pt" page-break-after="avoid" id="PIVOT">
<fo:marker marker-class-name="section">
<fo:block>4.5. The Oracle 11g PIVOT clause</fo:block>
</fo:marker>4.5. The Oracle 11g PIVOT clause</fo:block>
<fo:block>4.6. The Oracle 11g PIVOT clause</fo:block>
</fo:marker>4.6. The Oracle 11g PIVOT clause</fo:block>
<fo:block font-size="11pt">
Oracle 11g has formally introduced the very powerful PIVOT clause, which
allows to specify a pivot column, expected grouping values for pivoting,
@ -5798,8 +6064,8 @@ create.select(create.rownum())
</fo:block>
<fo:block font-family="Georgia" font-size="18pt" padding-top="12pt" padding-bottom="12pt" page-break-after="avoid" id="Export">
<fo:marker marker-class-name="section">
<fo:block>4.6. Exporting to XML, CSV, JSON, HTML, Text</fo:block>
</fo:marker>4.6. Exporting to XML, CSV, JSON, HTML, Text</fo:block>
<fo:block>4.7. Exporting to XML, CSV, JSON, HTML, Text</fo:block>
</fo:marker>4.7. Exporting to XML, CSV, JSON, HTML, Text</fo:block>
<fo:block font-size="11pt">
Get your data out of the Java world. Stream your data using any of the supported, wide-spread formats
</fo:block>
@ -5897,8 +6163,8 @@ String text = create.selectFrom(T_BOOK).fetch().format();</fo:block>
+---+---------+-----------+</fo:block>
<fo:block font-family="Georgia" font-size="18pt" padding-top="12pt" padding-bottom="12pt" page-break-after="avoid" id="Import">
<fo:marker marker-class-name="section">
<fo:block>4.7. Importing data from XML, CSV</fo:block>
</fo:marker>4.7. Importing data from XML, CSV</fo:block>
<fo:block>4.8. Importing data from XML, CSV</fo:block>
</fo:marker>4.8. Importing data from XML, CSV</fo:block>
<fo:block font-size="11pt">
Use jOOQ to easily merge imported data into your database.
</fo:block>
@ -6007,8 +6273,8 @@ Query query = error.query();]]></fo:block>
<fo:block font-size="11pt">This will be implemented soon... </fo:block>
<fo:block font-family="Georgia" font-size="18pt" padding-top="12pt" padding-bottom="12pt" page-break-after="avoid" id="Batch">
<fo:marker marker-class-name="section">
<fo:block>4.8. Using JDBC batch operations</fo:block>
</fo:marker>4.8. Using JDBC batch operations</fo:block>
<fo:block>4.9. Using JDBC batch operations</fo:block>
</fo:marker>4.9. Using JDBC batch operations</fo:block>
<fo:block font-size="11pt">
Some JDBC drivers have highly optimised means of executing batch
operations. The JDBC interface for those operations is a bit verbose.

View File

@ -131,6 +131,9 @@ function printContent() {
<a title="Configuration and setup of the generator" href="#Configuration">Configuration and setup of the generator</a>
</li>
<li>
<a title="Advanced configuration of the generator" href="#AdvancedConfiguration">Advanced configuration of the generator</a>
</li>
<li>
<a title="The schema, top-level generated artefact" href="#SCHEMA">The schema, top-level generated artefact</a>
</li>
<li>
@ -204,6 +207,9 @@ function printContent() {
<a title="Mapping generated schemata and tables" href="#SchemaMapping">Mapping generated schemata and tables</a>
</li>
<li>
<a title="Execute listeners and SQL tracing" href="#ExecuteListener">Execute listeners and SQL tracing</a>
</li>
<li>
<a title="Adding Oracle hints to queries" href="#OracleHints">Adding Oracle hints to queries</a>
</li>
<li>
@ -344,16 +350,43 @@ CREATE TABLE t_book_to_book_store (
lifecycle of your Factory</li>
<li>
<a href="https://github.com/lukaseder/jOOQ/blob/master/jOOQ/src/main/java/org/jooq/SchemaMapping.java" title="Internal API reference: org.jooq.SchemaMapping">org.jooq.SchemaMapping</a> :
An optional mapping of schemata. Check out the
<a href="#SchemaMapping" title="jOOQ Manual reference: Mapping generated schemata and tables">SchemaMapping</a>
page for details</li>
<a href="https://github.com/lukaseder/jOOQ/blob/master/jOOQ/src/main/java/org/jooq/conf/Settings.java" title="Internal API reference: org.jooq.conf.Settings">org.jooq.conf.Settings</a> :
An optional runtime configuration.</li>
</ul>
<p>If you are planning on using several RDBMS (= SQLDialects) or
several distinct JDBC Connections in your software, this will mean
that you have to create a new Factory every time. </p>
<h3>Factory settings</h3>
<p>
The jOOQ Factory allows for some optional configuration elements to be used by advanced users.
The <a href="https://github.com/lukaseder/jOOQ/blob/master/jOOQ/src/main/java/org/jooq/conf/Settings.java" title="Internal API reference: org.jooq.conf.Settings">Settings</a> class is a JAXB-annotated
type. In future releases of jOOQ, these settings can be loaded from an XML file automatically.
Subsequent sections of the manual contain some more in-depth explanations about these settings:
</p>
<ul>
<li>
<a href="#SchemaMapping" title="jOOQ Manual reference: Mapping generated schemata and tables">Runtime schema and table mapping</a>
</li>
<li>
<a href="#ExecuteListener" title="jOOQ Manual reference: Execute listeners and SQL tracing">Execute listeners and SQL tracing</a>
</li>
</ul>
<p>
Please refer to the jOOQ runtime configuration XSD for more details:<br>
<a href="http://www.jooq.org/xsd/jooq-runtime-2.0.5.xsd" title="The jOOQ Runtime configuration XSD">http://www.jooq.org/xsd/jooq-runtime-2.0.5.xsd</a>
</p>
<h3>Factory subclasses</h3>
<p>
There are a couple of subclasses for the general Factory. Each SQL
@ -1227,6 +1260,9 @@ Object[] fetchArray(String fieldName);
// Fetch a Cursor for lazy iteration
Cursor&lt;R&gt; fetchLazy();
// Or a JDBC ResultSet, if you prefer that
ResultSet fetchResultSet();
// Fetch data asynchronously and let client code
// decide, when the data must be available.
// This makes use of the java.util.concurrent API,
@ -1621,17 +1657,6 @@ public void bind(BindContext context) throws DataAccessException;</pre>
&lt;/jdbc&gt;
&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;
&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;
&lt;database&gt;
&lt;!-- The database dialect from jooq-meta. Available dialects are
named org.util.[database].[database]Database. Known values are:
@ -1687,97 +1712,10 @@ public void bind(BindContext context) throws DataAccessException;</pre>
&lt;/generator&gt;
&lt;/configuration&gt;</pre>
<p>And you can add some optional advanced configuration parameters for the database: </p>
<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;
&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;
&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>
<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
<p>
There are also lots of advanced configuration parameters, which will be
treated in the <a href="#AdvancedConfiguration" title="jOOQ Manual reference: Advanced configuration of the generator">manual's next section</a>
Note, you can find 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>
@ -1958,8 +1896,210 @@ public void bind(BindContext context) throws DataAccessException;</pre>
<p>Be sure, both jOOQ.jar and your generated package (see
configuration) are located on your classpath. Once this is done, you
can execute SQL statements with your generated classes.</p>
<h1 id="AdvancedConfiguration">
<a name="AdvancedConfiguration"></a>2.2. Advanced configuration of the generator</h1><p>jOOQ power users may want to fine-tune their source code generation settings. Here's how to do this</p>
<h2>Code generation</h2>
<p>
In the <a href="#Configuration" title="jOOQ Manual reference: Configuration and setup of the generator">previous section</a>
we have seen how jOOQ's source code generator is configured and
run within a few steps. In this chapter we'll treat some advanced
settings
</p>
<pre class="prettyprint lang-xml">&lt;!-- These properties can be added directly to the generator element: --&gt;
&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;
&lt;!-- The naming strategy used for class and field names.
You may override this with your custom naming strategy. Some examples follow
Defaults to org.jooq.util.DefaultGeneratorStrategy --&gt;
&lt;strategy&gt;
&lt;name&gt;org.jooq.util.DefaultGeneratorStrategy&lt;/name&gt;
&lt;/strategy&gt;
&lt;/generator&gt;</pre>
<p>
The following example shows how you can override the
DefaultGeneratorStrategy to render table and column names the way
they are defined in the database, rather than switching them to
camel case:
</p>
<pre class="prettyprint lang-java">/**
* It is recommended that you extend the DefaultGeneratorStrategy. Most of the
* GeneratorStrategy API is already declared final. You only need to override any
* of the following methods, for whatever generation behaviour you'd like to achieve
*
* Beware that most methods also receive a "Mode" object, to tell you whether a
* TableDefinition is being rendered as a Table, Record, POJO, etc. Depending on
* that information, you can add a suffix only for TableRecords, not for Tables
*/
public class AsInDatabaseStrategy extends DefaultGeneratorStrategy {
/**
* Override this to specifiy what identifiers in Java should look like.
* This will just take the identifier as defined in the database.
*/
@Override
public String getJavaIdentifier(Definition definition) {
return definition.getOutputName();
}
/**
* Override these to specify what a setter in Java should look like. Setters
* are used in TableRecords, UDTRecords, and POJOs. This example will name
* setters "set[NAME_IN_DATABASE]"
*/
@Override
public String getJavaSetterName(Definition definition, Mode mode) {
return "set" + definition.getOutputName();
}
/**
* Just like setters...
*/
@Override
public String getJavaGetterName(Definition definition, Mode mode) {
return "get" + definition.getOutputName();
}
/**
* Override this method to define what a Java method generated from a database
* Definition should look like. This is used mostly for convenience methods
* when calling stored procedures and functions. This example shows how to
* set a prefix to a CamelCase version of your procedure
*/
@Override
public String getJavaMethodName(Definition definition, Mode mode) {
return "call" + org.jooq.tools.StringUtils.toCamelCase(definition.getOutputName());
}
/**
* Override this method to define how your Java classes and Java files should
* be named. This example applies no custom setting and uses CamelCase versions
* instead
*/
@Override
public String getJavaClassName(Definition definition, Mode mode) {
return super.getJavaClassName(definition, mode);
}
/**
* Override this method to re-define the package names of your generated
* artefacts.
*/
@Override
public String getJavaPackageName(Definition definition, Mode mode) {
return super.getJavaPackageName(definition, mode);
}
/**
* Override this method to define how Java members should be named. This is
* used for POJOs and method arguments
*/
@Override
public String getJavaMemberName(Definition definition, Mode mode) {
return definition.getOutputName();
}
}</pre>
<p>
Within the &lt;generator/&gt; element, there are other configuration elements:
</p>
<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;
&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;
&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>
<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>
<h1 id="SCHEMA">
<a name="SCHEMA"></a>2.2. The schema, top-level generated artefact</h1><p>The schema is the top-level generated object in jOOQ. In many
<a name="SCHEMA"></a>2.3. The schema, top-level generated artefact</h1><p>The schema is the top-level generated object in jOOQ. In many
RDBMS, the schema coincides with the owner of tables and other objects
</p>
<h2>The Schema</h2>
@ -1994,7 +2134,7 @@ public void bind(BindContext context) throws DataAccessException;</pre>
<pre class="prettyprint lang-java">public final java.util.List&lt;org.jooq.Sequence&lt;?&gt;&gt; getSequences();
public final java.util.List&lt;org.jooq.Table&lt;?&gt;&gt; getTables();</pre>
<h1 id="TABLE">
<a name="TABLE"></a>2.3. Tables, views and their corresponding records</h1><p>
<a name="TABLE"></a>2.4. Tables, views and their corresponding records</h1><p>
The most important generated artefacts are Tables and TableRecords.
Every Table has a Record type associated with it that models a single tuple
of that entity: Table&lt;R extends Record&gt;.
@ -2065,7 +2205,7 @@ public final java.util.List&lt;org.jooq.Table&lt;?&gt;&gt; getTables();</pre>
public List&lt;TBookRecord&gt; fetchTBooks() { // [...]
}</pre>
<h1 id="PROCEDURE">
<a name="PROCEDURE"></a>2.4. Procedures and packages</h1><p>
<a name="PROCEDURE"></a>2.5. Procedures and packages</h1><p>
Procedure support is one of the most important reasons why you should consider
jOOQ. jOOQ heavily facilitates the use of stored procedures and
functions via its source code generation.
@ -2264,7 +2404,7 @@ assertNotNull(author.getLastName());</pre>
</p>
<h1 id="UDT">
<a name="UDT"></a>2.5. UDT's including ARRAY and ENUM types</h1><p>
<a name="UDT"></a>2.6. UDT's including ARRAY and ENUM types</h1><p>
Databases become more powerful when you can structure your data in user
defined types. It's time for Java developers to give some credit to
that.
@ -2564,7 +2704,7 @@ public class TBookRecord extends UpdatableRecordImpl&lt;TBookRecord&gt; {
<a href="#MasterData" title="jOOQ Manual reference: Master data generation. Enumeration tables">master data</a> for more
details. </p>
<h1 id="SEQUENCE">
<a name="SEQUENCE"></a>2.6. Sequences</h1><p>
<a name="SEQUENCE"></a>2.7. Sequences</h1><p>
jOOQ also generates convenience artefacts for sequences, where this is
supported: DB2, Derby, H2, HSQLDB, Oracle, Postgres, and more.
</p>
@ -3020,6 +3160,8 @@ TableOnConditionStep onKey(ForeignKey&lt;?, ?&gt; key);</pre>
Condition notIn(Select&lt;?&gt; query);
Condition in(Collection&lt;T&gt; values);
Condition between(T minValue, T maxValue);
Condition contains(T value);
Condition contains(Field&lt;T&gt; value);
Condition equal(T value);
Condition equal(Field&lt;T&gt; field);
Condition equal(Select&lt;?&gt; query);
@ -3029,6 +3171,8 @@ TableOnConditionStep onKey(ForeignKey&lt;?, ?&gt; key);</pre>
Condition equalAll(Select&lt;?&gt; query);
Condition equalAll(T... array);
Condition equalAll(Field&lt;T[]&gt; array);
Condition equalIgnoreCase(String value);
Condition equalIgnoreCase(Field&lt;String&gt; value);
Condition notEqual(T value);
Condition notEqual(Field&lt;T&gt; field);
Condition notEqual(Select&lt;?&gt; query);
@ -4152,15 +4296,18 @@ create.select(LAST_NAME, COUNT1, COUNT2)
<p>When a user from My Book World logs in, you want them to access the
MY_BOOK_WORLD schema using classes generated from DEV. This can be
achieved with the
<a href="https://github.com/lukaseder/jOOQ/blob/master/jOOQ/src/main/java/org/jooq/SchemaMapping.java" title="Internal API reference: org.jooq.SchemaMapping">org.jooq.SchemaMapping</a>
class, that you can equip your Factory
<a href="https://github.com/lukaseder/jOOQ/blob/master/jOOQ/src/main/java/org/jooq/conf/RenderMapping.java" title="Internal API reference: org.jooq.conf.RenderMapping">org.jooq.conf.RenderMapping</a>
class, that you can equip your Factory's settings
with. Take the following example: </p>
<pre class="prettyprint lang-java">SchemaMapping mapping = new SchemaMapping();
mapping.add(DEV, "MY_BOOK_WORLD");
<pre class="prettyprint lang-java">Settings settings = new Settings()
.withRenderMapping(new RenderMapping()
.withSchemata(
new MappedSchema().withInput("DEV")
.withOutput("MY_BOOK_WORLD")));
// Add the mapping to the factory
Factory create = new Factory(connection, SQLDialect.ORACLE, mapping);
// Add the settings to the factory
Factory create = new Factory(connection, SQLDialect.ORACLE, settings);
// Run queries with the "mapped" factory
create.selectFrom(T_AUTHOR).fetch();</pre>
@ -4174,12 +4321,27 @@ create.selectFrom(T_AUTHOR).fetch();</pre>
<p>Your development database may not be restricted to hold only one DEV
schema. You may also have a LOG schema and a MASTER schema. Let's say
the MASTER schema is shared among all customers, but each customer has
their own LOG schema instance. Then you can enhance your SchemaMapping
like this: </p>
their own LOG schema instance. Then you can enhance your RenderMapping
like this (e.g. using an XML configuration file): </p>
<pre class="prettyprint lang-java">SchemaMapping mapping = new SchemaMapping();
mapping.add(DEV, "MY_BOOK_WORLD");
mapping.add(LOG, "MY_BOOK_WORLD_LOG");</pre>
<pre class="prettyprint lang-xml">&lt;settings xmlns="http://www.jooq.org/xsd/jooq-runtime-2.0.5.xsd"&gt;
&lt;renderMapping&gt;
&lt;schemata&gt;
&lt;schema&gt;
&lt;input&gt;DEV&lt;/input&gt;
&lt;output&gt;MY_BOOK_WORLD&lt;/output&gt;
&lt;/schema&gt;
&lt;schema&gt;
&lt;input&gt;LOG&lt;/input&gt;
&lt;output&gt;MY_BOOK_WORLD_LOG&lt;/output&gt;
&lt;/schema&gt;
&lt;/schemata&gt;
&lt;/renderMapping&gt;
&lt;/settings&gt;</pre>
<p>Note, you can load the above XML file like this:</p>
<pre class="prettyprint lang-java">Settings settings = JAXB.unmarshal(new File("jooq-runtime.xml"), Settings.class);</pre>
<p>This will map generated classes from DEV to MY_BOOK_WORLD, from LOG
to MY_BOOK_WORLD_LOG, but leave the MASTER schema alone. Whenever you
@ -4213,12 +4375,17 @@ SELECT * FROM T_AUTHOR</pre>
applied to all of your tables. This can be achieved by creating the
following mapping: </p>
<pre class="prettyprint lang-java">SchemaMapping mapping = new SchemaMapping();
mapping.add(DEV, "MY_BOOK_WORLD");
mapping.add(T_AUTHOR, "MY_APP__T_AUTHOR");
<pre class="prettyprint lang-java">Settings settings = new Settings()
.withRenderMapping(new RenderMapping()
.withSchemata(
new MappedSchema().withInput("DEV")
.withOutput("MY_BOOK_WORLD")
.withTables(
new MappedTable().withInput("T_AUTHOR")
.withOutput("MY_APP__T_AUTHOR"))));
// Add the mapping to the factory
Factory create = new Factory(connection, SQLDialect.ORACLE, mapping);
// Add the settings to the factory
Factory create = new Factory(connection, SQLDialect.ORACLE, settings);
// Run queries with the "mapped" factory
create.selectFrom(T_AUTHOR).fetch();</pre>
@ -4247,8 +4414,68 @@ create.selectFrom(T_AUTHOR).fetch();</pre>
<a href="#META" title="jOOQ Manual reference: Meta model code generation">jooq-codegen configuration</a>
for more details
</p>
<h1 id="ExecuteListener">
<a name="ExecuteListener"></a>4.3. Execute listeners and SQL tracing</h1><p>
Feel the heart beat of your SQL statements at a very low level using listeners
</p>
<h2>ExecuteListener</h2>
<p>
The <a href="#Factory" title="jOOQ Manual reference: The Factory class">jOOQ Factory Settings</a>
let you specify a list of <a href="https://github.com/lukaseder/jOOQ/blob/master/jOOQ/src/main/java/org/jooq/ExecuteListener.java" title="Internal API reference: org.jooq.ExecuteListener">org.jooq.ExecuteListener</a> classes.
The ExecuteListener is essentially an event listener for
Query, Routine, or ResultSet render, prepare, bind, execute, fetch steps. It is a
base type for loggers, debuggers, profilers, data collectors. Advanced ExecuteListeners
can also provide custom implementations of Connection, PreparedStatement and ResultSet
to jOOQ in apropriate methods. For convenience, consider extending
<a href="https://github.com/lukaseder/jOOQ/blob/master/jOOQ/src/main/java/org/jooq/impl/DefaultExecuteListener.java" title="Internal API reference: org.jooq.impl.DefaultExecuteListener">org.jooq.impl.DefaultExecuteListener</a>
instead of implementing this interface. Please read the
<a href="www.jooq.org/javadoc/latest/org/jooq/ExecuteListener.html" title="ExecuteListener Javadoc">ExecuteListener Javadoc</a>
for more details
</p>
<h2>jOOQ Console</h2>
<p>
The ExecuteListener API was driven by a feature request by Christopher Deckers, who has
had the courtesy to contribute the jOOQ Console, a sample application interfacing
with jOOQ's ExecuteListeners. Please note that the jOOQ Console is still experimental.
Any feedback is very welcome on
<a href="http://groups.google.com/group/jooq-user" title="the jooq-user group">the jooq-user group</a>
</p>
<p>
Here are the steps you need to do to run the console
</p>
<pre class="prettyprint lang-java">// Create a new RemoteDebuggerServer in your application that listens to
// incoming connections on a given port
SERVER = new RemoteDebuggerServer(DEBUGGER_PORT);</pre>
<p>
And configure the <a href="https://github.com/lukaseder/jOOQ/blob/master/jOOQ/src/main/java/org/jooq/debug/DebugListener.java" title="Internal API reference: org.jooq.debug.DebugListener">org.jooq.debug.DebugListener</a> in the
Factory's settings:
</p>
<pre class="prettyprint lang-xml">&lt;settings&gt;
&lt;executeListeners&gt;
&lt;executeListener&gt;org.jooq.debug.DebugListener&lt;/executeListener&gt;
&lt;/executeListeners&gt;
&lt;/settings&gt;</pre>
<p>
Now start your application and the
<a href="https://github.com/lukaseder/jOOQ/blob/master/jOOQ/src/main/java/org/jooq/debug/console/Console.java" title="Internal API reference: org.jooq.debug.console.Console">org.jooq.debug.console.Console</a>, and start profiling!
</p>
<div class="screenshot">
<img alt="jOOQ Console example" class="screenshot" src="<?=$root?>/img/jooq-console-01.png">
</div>
<p>
The jOOQ Console also has other modes of execution, which will be documented here
soon.
</p>
<h1 id="OracleHints">
<a name="OracleHints"></a>4.3. Adding Oracle hints to queries</h1><p>
<a name="OracleHints"></a>4.4. Adding Oracle hints to queries</h1><p>
Oracle has a powerful syntax to add hints as comments directly in your SQL
</p>
<h2>How to embed Oracle hints in SELECT</h2>
@ -4267,7 +4494,7 @@ create.selectFrom(T_AUTHOR).fetch();</pre>
that clause, the passed string will always be put in between the
SELECT [DISTINCT] keywords and the actual projection list </p>
<h1 id="CONNECTBY">
<a name="CONNECTBY"></a>4.4. The Oracle CONNECT BY clause</h1><p>
<a name="CONNECTBY"></a>4.5. The Oracle CONNECT BY clause</h1><p>
Hierarchical queries are supported by many RDBMS using the WITH clause.
Oracle has a very neat and much less verbose syntax for hierarchical
queries: CONNECT BY .. STARTS WITH
@ -4318,7 +4545,7 @@ create.select(create.rownum())
|...21 record(s) truncated...
</pre>
<h1 id="PIVOT">
<a name="PIVOT"></a>4.5. The Oracle 11g PIVOT clause</h1><p>
<a name="PIVOT"></a>4.6. The Oracle 11g PIVOT clause</h1><p>
Oracle 11g has formally introduced the very powerful PIVOT clause, which
allows to specify a pivot column, expected grouping values for pivoting,
as well as a set of aggregate functions
@ -4341,7 +4568,7 @@ create.select(create.rownum())
dialects in the future.
</p>
<h1 id="Export">
<a name="Export"></a>4.6. Exporting to XML, CSV, JSON, HTML, Text</h1><p>
<a name="Export"></a>4.7. Exporting to XML, CSV, JSON, HTML, Text</h1><p>
Get your data out of the Java world. Stream your data using any of the supported, wide-spread formats
</p>
<h2>Exporting with jOOQ</h2>
@ -4437,7 +4664,7 @@ String text = create.selectFrom(T_BOOK).fetch().format();</pre>
| 2| 1|Animal Farm|
+---+---------+-----------+</pre>
<h1 id="Import">
<a name="Import"></a>4.7. Importing data from XML, CSV</h1><p>
<a name="Import"></a>4.8. Importing data from XML, CSV</h1><p>
Use jOOQ to easily merge imported data into your database.
</p>
<h2>Importing with jOOQ</h2>
@ -4544,7 +4771,7 @@ Query query = error.query();</pre>
<h3>XML </h3>
<p>This will be implemented soon... </p>
<h1 id="Batch">
<a name="Batch"></a>4.8. Using JDBC batch operations</h1><p>
<a name="Batch"></a>4.9. Using JDBC batch operations</h1><p>
Some JDBC drivers have highly optimised means of executing batch
operations. The JDBC interface for those operations is a bit verbose.
jOOQ abstracts that by re-using the existing query API's

View File

@ -0,0 +1,89 @@
<?php
// The following content has been XSL transformed from manual.xml using html-pages.xsl
// Please do not edit this content manually
require '../../../frame.php';
function getH1() {
return "Execute listeners and SQL tracing";
}
function getActiveMenu() {
return "manual";
}
function getSlogan() {
return "
Feel the heart beat of your SQL statements at a very low level using listeners
";
}
function printContent() {
global $root;
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" align="left"><a href="<?=$root?>/manual/">The jOOQ User Manual</a> : <a href="<?=$root?>/manual/ADVANCED/">Advanced topics</a> : <a href="<?=$root?>/manual/ADVANCED/ExecuteListener/">Execute listeners and SQL tracing</a></td><td style="white-space: nowrap" valign="top" align="right"><a title="Previous section: Mapping generated schemata and tables" href="<?=$root?>/manual/ADVANCED/SchemaMapping/">previous</a> : <a title="Next section: Adding Oracle hints to queries" href="<?=$root?>/manual/ADVANCED/OracleHints/">next</a></td>
</tr>
</table>
<h2>ExecuteListener</h2>
<p>
The <a href="<?=$root?>/manual/JOOQ/Factory/" title="jOOQ Manual reference: The Factory class">jOOQ Factory Settings</a>
let you specify a list of <a href="https://github.com/lukaseder/jOOQ/blob/master/jOOQ/src/main/java/org/jooq/ExecuteListener.java" title="Internal API reference: org.jooq.ExecuteListener">org.jooq.ExecuteListener</a> classes.
The ExecuteListener is essentially an event listener for
Query, Routine, or ResultSet render, prepare, bind, execute, fetch steps. It is a
base type for loggers, debuggers, profilers, data collectors. Advanced ExecuteListeners
can also provide custom implementations of Connection, PreparedStatement and ResultSet
to jOOQ in apropriate methods. For convenience, consider extending
<a href="https://github.com/lukaseder/jOOQ/blob/master/jOOQ/src/main/java/org/jooq/impl/DefaultExecuteListener.java" title="Internal API reference: org.jooq.impl.DefaultExecuteListener">org.jooq.impl.DefaultExecuteListener</a>
instead of implementing this interface. Please read the
<a href="www.jooq.org/javadoc/latest/org/jooq/ExecuteListener.html" title="ExecuteListener Javadoc">ExecuteListener Javadoc</a>
for more details
</p>
<h2>jOOQ Console</h2>
<p>
The ExecuteListener API was driven by a feature request by Christopher Deckers, who has
had the courtesy to contribute the jOOQ Console, a sample application interfacing
with jOOQ's ExecuteListeners. Please note that the jOOQ Console is still experimental.
Any feedback is very welcome on
<a href="http://groups.google.com/group/jooq-user" title="the jooq-user group">the jooq-user group</a>
</p>
<p>
Here are the steps you need to do to run the console
</p>
<pre class="prettyprint lang-java">// Create a new RemoteDebuggerServer in your application that listens to
// incoming connections on a given port
SERVER = new RemoteDebuggerServer(DEBUGGER_PORT);</pre>
<p>
And configure the <a href="https://github.com/lukaseder/jOOQ/blob/master/jOOQ/src/main/java/org/jooq/debug/DebugListener.java" title="Internal API reference: org.jooq.debug.DebugListener">org.jooq.debug.DebugListener</a> in the
Factory's settings:
</p>
<pre class="prettyprint lang-xml">&lt;settings&gt;
&lt;executeListeners&gt;
&lt;executeListener&gt;org.jooq.debug.DebugListener&lt;/executeListener&gt;
&lt;/executeListeners&gt;
&lt;/settings&gt;</pre>
<p>
Now start your application and the
<a href="https://github.com/lukaseder/jOOQ/blob/master/jOOQ/src/main/java/org/jooq/debug/console/Console.java" title="Internal API reference: org.jooq.debug.console.Console">org.jooq.debug.console.Console</a>, and start profiling!
</p>
<div class="screenshot">
<img alt="jOOQ Console example" class="screenshot" src="<?=$root?>/img/jooq-console-01.png">
</div>
<p>
The jOOQ Console also has other modes of execution, which will be documented here
soon.
</p>
<br><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" align="left"><a href="<?=$root?>/manual/">The jOOQ User Manual</a> : <a href="<?=$root?>/manual/ADVANCED/">Advanced topics</a> : <a href="<?=$root?>/manual/ADVANCED/ExecuteListener/">Execute listeners and SQL tracing</a></td><td style="white-space: nowrap" valign="top" align="right"><a title="Previous section: Mapping generated schemata and tables" href="<?=$root?>/manual/ADVANCED/SchemaMapping/">previous</a> : <a title="Next section: Adding Oracle hints to queries" href="<?=$root?>/manual/ADVANCED/OracleHints/">next</a></td>
</tr>
</table>
<?php
}
?>

View File

@ -19,7 +19,7 @@ function printContent() {
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" align="left"><a href="<?=$root?>/manual/">The jOOQ User Manual</a> : <a href="<?=$root?>/manual/ADVANCED/">Advanced topics</a> : <a href="<?=$root?>/manual/ADVANCED/OracleHints/">Adding Oracle hints to queries</a></td><td style="white-space: nowrap" valign="top" align="right"><a title="Previous section: Mapping generated schemata and tables" href="<?=$root?>/manual/ADVANCED/SchemaMapping/">previous</a> : <a title="Next section: The Oracle CONNECT BY clause" href="<?=$root?>/manual/ADVANCED/CONNECTBY/">next</a></td>
<td valign="top" align="left"><a href="<?=$root?>/manual/">The jOOQ User Manual</a> : <a href="<?=$root?>/manual/ADVANCED/">Advanced topics</a> : <a href="<?=$root?>/manual/ADVANCED/OracleHints/">Adding Oracle hints to queries</a></td><td style="white-space: nowrap" valign="top" align="right"><a title="Previous section: Execute listeners and SQL tracing" href="<?=$root?>/manual/ADVANCED/ExecuteListener/">previous</a> : <a title="Next section: The Oracle CONNECT BY clause" href="<?=$root?>/manual/ADVANCED/CONNECTBY/">next</a></td>
</tr>
</table>
<h2>How to embed Oracle hints in SELECT</h2>
@ -39,7 +39,7 @@ function printContent() {
SELECT [DISTINCT] keywords and the actual projection list </p>
<br><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" align="left"><a href="<?=$root?>/manual/">The jOOQ User Manual</a> : <a href="<?=$root?>/manual/ADVANCED/">Advanced topics</a> : <a href="<?=$root?>/manual/ADVANCED/OracleHints/">Adding Oracle hints to queries</a></td><td style="white-space: nowrap" valign="top" align="right"><a title="Previous section: Mapping generated schemata and tables" href="<?=$root?>/manual/ADVANCED/SchemaMapping/">previous</a> : <a title="Next section: The Oracle CONNECT BY clause" href="<?=$root?>/manual/ADVANCED/CONNECTBY/">next</a></td>
<td valign="top" align="left"><a href="<?=$root?>/manual/">The jOOQ User Manual</a> : <a href="<?=$root?>/manual/ADVANCED/">Advanced topics</a> : <a href="<?=$root?>/manual/ADVANCED/OracleHints/">Adding Oracle hints to queries</a></td><td style="white-space: nowrap" valign="top" align="right"><a title="Previous section: Execute listeners and SQL tracing" href="<?=$root?>/manual/ADVANCED/ExecuteListener/">previous</a> : <a title="Next section: The Oracle CONNECT BY clause" href="<?=$root?>/manual/ADVANCED/CONNECTBY/">next</a></td>
</tr>
</table>
<?php

View File

@ -21,7 +21,7 @@ function printContent() {
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" align="left"><a href="<?=$root?>/manual/">The jOOQ User Manual</a> : <a href="<?=$root?>/manual/ADVANCED/">Advanced topics</a> : <a href="<?=$root?>/manual/ADVANCED/SchemaMapping/">Mapping generated schemata and tables</a></td><td style="white-space: nowrap" valign="top" align="right"><a title="Previous section: Master data generation. Enumeration tables" href="<?=$root?>/manual/ADVANCED/MasterData/">previous</a> : <a title="Next section: Adding Oracle hints to queries" href="<?=$root?>/manual/ADVANCED/OracleHints/">next</a></td>
<td valign="top" align="left"><a href="<?=$root?>/manual/">The jOOQ User Manual</a> : <a href="<?=$root?>/manual/ADVANCED/">Advanced topics</a> : <a href="<?=$root?>/manual/ADVANCED/SchemaMapping/">Mapping generated schemata and tables</a></td><td style="white-space: nowrap" valign="top" align="right"><a title="Previous section: Master data generation. Enumeration tables" href="<?=$root?>/manual/ADVANCED/MasterData/">previous</a> : <a title="Next section: Execute listeners and SQL tracing" href="<?=$root?>/manual/ADVANCED/ExecuteListener/">next</a></td>
</tr>
</table>
<h2>Mapping your DEV schema to a productive environment</h2>
@ -50,15 +50,18 @@ function printContent() {
<p>When a user from My Book World logs in, you want them to access the
MY_BOOK_WORLD schema using classes generated from DEV. This can be
achieved with the
<a href="https://github.com/lukaseder/jOOQ/blob/master/jOOQ/src/main/java/org/jooq/SchemaMapping.java" title="Internal API reference: org.jooq.SchemaMapping">org.jooq.SchemaMapping</a>
class, that you can equip your Factory
<a href="https://github.com/lukaseder/jOOQ/blob/master/jOOQ/src/main/java/org/jooq/conf/RenderMapping.java" title="Internal API reference: org.jooq.conf.RenderMapping">org.jooq.conf.RenderMapping</a>
class, that you can equip your Factory's settings
with. Take the following example: </p>
<pre class="prettyprint lang-java">SchemaMapping mapping = new SchemaMapping();
mapping.add(DEV, "MY_BOOK_WORLD");
<pre class="prettyprint lang-java">Settings settings = new Settings()
.withRenderMapping(new RenderMapping()
.withSchemata(
new MappedSchema().withInput("DEV")
.withOutput("MY_BOOK_WORLD")));
// Add the mapping to the factory
Factory create = new Factory(connection, SQLDialect.ORACLE, mapping);
// Add the settings to the factory
Factory create = new Factory(connection, SQLDialect.ORACLE, settings);
// Run queries with the "mapped" factory
create.selectFrom(T_AUTHOR).fetch();</pre>
@ -72,12 +75,27 @@ create.selectFrom(T_AUTHOR).fetch();</pre>
<p>Your development database may not be restricted to hold only one DEV
schema. You may also have a LOG schema and a MASTER schema. Let's say
the MASTER schema is shared among all customers, but each customer has
their own LOG schema instance. Then you can enhance your SchemaMapping
like this: </p>
their own LOG schema instance. Then you can enhance your RenderMapping
like this (e.g. using an XML configuration file): </p>
<pre class="prettyprint lang-java">SchemaMapping mapping = new SchemaMapping();
mapping.add(DEV, "MY_BOOK_WORLD");
mapping.add(LOG, "MY_BOOK_WORLD_LOG");</pre>
<pre class="prettyprint lang-xml">&lt;settings xmlns="http://www.jooq.org/xsd/jooq-runtime-2.0.5.xsd"&gt;
&lt;renderMapping&gt;
&lt;schemata&gt;
&lt;schema&gt;
&lt;input&gt;DEV&lt;/input&gt;
&lt;output&gt;MY_BOOK_WORLD&lt;/output&gt;
&lt;/schema&gt;
&lt;schema&gt;
&lt;input&gt;LOG&lt;/input&gt;
&lt;output&gt;MY_BOOK_WORLD_LOG&lt;/output&gt;
&lt;/schema&gt;
&lt;/schemata&gt;
&lt;/renderMapping&gt;
&lt;/settings&gt;</pre>
<p>Note, you can load the above XML file like this:</p>
<pre class="prettyprint lang-java">Settings settings = JAXB.unmarshal(new File("jooq-runtime.xml"), Settings.class);</pre>
<p>This will map generated classes from DEV to MY_BOOK_WORLD, from LOG
to MY_BOOK_WORLD_LOG, but leave the MASTER schema alone. Whenever you
@ -111,12 +129,17 @@ SELECT * FROM T_AUTHOR</pre>
applied to all of your tables. This can be achieved by creating the
following mapping: </p>
<pre class="prettyprint lang-java">SchemaMapping mapping = new SchemaMapping();
mapping.add(DEV, "MY_BOOK_WORLD");
mapping.add(T_AUTHOR, "MY_APP__T_AUTHOR");
<pre class="prettyprint lang-java">Settings settings = new Settings()
.withRenderMapping(new RenderMapping()
.withSchemata(
new MappedSchema().withInput("DEV")
.withOutput("MY_BOOK_WORLD")
.withTables(
new MappedTable().withInput("T_AUTHOR")
.withOutput("MY_APP__T_AUTHOR"))));
// Add the mapping to the factory
Factory create = new Factory(connection, SQLDialect.ORACLE, mapping);
// Add the settings to the factory
Factory create = new Factory(connection, SQLDialect.ORACLE, settings);
// Run queries with the "mapped" factory
create.selectFrom(T_AUTHOR).fetch();</pre>
@ -147,7 +170,7 @@ create.selectFrom(T_AUTHOR).fetch();</pre>
</p>
<br><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" align="left"><a href="<?=$root?>/manual/">The jOOQ User Manual</a> : <a href="<?=$root?>/manual/ADVANCED/">Advanced topics</a> : <a href="<?=$root?>/manual/ADVANCED/SchemaMapping/">Mapping generated schemata and tables</a></td><td style="white-space: nowrap" valign="top" align="right"><a title="Previous section: Master data generation. Enumeration tables" href="<?=$root?>/manual/ADVANCED/MasterData/">previous</a> : <a title="Next section: Adding Oracle hints to queries" href="<?=$root?>/manual/ADVANCED/OracleHints/">next</a></td>
<td valign="top" align="left"><a href="<?=$root?>/manual/">The jOOQ User Manual</a> : <a href="<?=$root?>/manual/ADVANCED/">Advanced topics</a> : <a href="<?=$root?>/manual/ADVANCED/SchemaMapping/">Mapping generated schemata and tables</a></td><td style="white-space: nowrap" valign="top" align="right"><a title="Previous section: Master data generation. Enumeration tables" href="<?=$root?>/manual/ADVANCED/MasterData/">previous</a> : <a title="Next section: Execute listeners and SQL tracing" href="<?=$root?>/manual/ADVANCED/ExecuteListener/">next</a></td>
</tr>
</table>
<?php

View File

@ -31,6 +31,9 @@ function printContent() {
<a title="Mapping generated schemata and tables" href="<?=$root?>/manual/ADVANCED/SchemaMapping/">Mapping generated schemata and tables</a>
</li>
<li>
<a title="Execute listeners and SQL tracing" href="<?=$root?>/manual/ADVANCED/ExecuteListener/">Execute listeners and SQL tracing</a>
</li>
<li>
<a title="Adding Oracle hints to queries" href="<?=$root?>/manual/ADVANCED/OracleHints/">Adding Oracle hints to queries</a>
</li>
<li>

View File

@ -71,6 +71,8 @@ function printContent() {
Condition notIn(Select&lt;?&gt; query);
Condition in(Collection&lt;T&gt; values);
Condition between(T minValue, T maxValue);
Condition contains(T value);
Condition contains(Field&lt;T&gt; value);
Condition equal(T value);
Condition equal(Field&lt;T&gt; field);
Condition equal(Select&lt;?&gt; query);
@ -80,6 +82,8 @@ function printContent() {
Condition equalAll(Select&lt;?&gt; query);
Condition equalAll(T... array);
Condition equalAll(Field&lt;T[]&gt; array);
Condition equalIgnoreCase(String value);
Condition equalIgnoreCase(Field&lt;String&gt; value);
Condition notEqual(T value);
Condition notEqual(Field&lt;T&gt; field);
Condition notEqual(Select&lt;?&gt; query);

View File

@ -58,16 +58,43 @@ function printContent() {
lifecycle of your Factory</li>
<li>
<a href="https://github.com/lukaseder/jOOQ/blob/master/jOOQ/src/main/java/org/jooq/SchemaMapping.java" title="Internal API reference: org.jooq.SchemaMapping">org.jooq.SchemaMapping</a> :
An optional mapping of schemata. Check out the
<a href="<?=$root?>/manual/ADVANCED/SchemaMapping/" title="jOOQ Manual reference: Mapping generated schemata and tables">SchemaMapping</a>
page for details</li>
<a href="https://github.com/lukaseder/jOOQ/blob/master/jOOQ/src/main/java/org/jooq/conf/Settings.java" title="Internal API reference: org.jooq.conf.Settings">org.jooq.conf.Settings</a> :
An optional runtime configuration.</li>
</ul>
<p>If you are planning on using several RDBMS (= SQLDialects) or
several distinct JDBC Connections in your software, this will mean
that you have to create a new Factory every time. </p>
<h3>Factory settings</h3>
<p>
The jOOQ Factory allows for some optional configuration elements to be used by advanced users.
The <a href="https://github.com/lukaseder/jOOQ/blob/master/jOOQ/src/main/java/org/jooq/conf/Settings.java" title="Internal API reference: org.jooq.conf.Settings">Settings</a> class is a JAXB-annotated
type. In future releases of jOOQ, these settings can be loaded from an XML file automatically.
Subsequent sections of the manual contain some more in-depth explanations about these settings:
</p>
<ul>
<li>
<a href="<?=$root?>/manual/ADVANCED/SchemaMapping/" title="jOOQ Manual reference: Mapping generated schemata and tables">Runtime schema and table mapping</a>
</li>
<li>
<a href="<?=$root?>/manual/ADVANCED/ExecuteListener/" title="jOOQ Manual reference: Execute listeners and SQL tracing">Execute listeners and SQL tracing</a>
</li>
</ul>
<p>
Please refer to the jOOQ runtime configuration XSD for more details:<br>
<a href="http://www.jooq.org/xsd/jooq-runtime-2.0.5.xsd" title="The jOOQ Runtime configuration XSD">http://www.jooq.org/xsd/jooq-runtime-2.0.5.xsd</a>
</p>
<h3>Factory subclasses</h3>
<p>
There are a couple of subclasses for the general Factory. Each SQL

View File

@ -92,6 +92,9 @@ Object[] fetchArray(String fieldName);
// Fetch a Cursor for lazy iteration
Cursor&lt;R&gt; fetchLazy();
// Or a JDBC ResultSet, if you prefer that
ResultSet fetchResultSet();
// Fetch data asynchronously and let client code
// decide, when the data must be available.
// This makes use of the java.util.concurrent API,

View File

@ -0,0 +1,231 @@
<?php
// The following content has been XSL transformed from manual.xml using html-pages.xsl
// Please do not edit this content manually
require '../../../frame.php';
function getH1() {
return "Advanced configuration of the generator";
}
function getActiveMenu() {
return "manual";
}
function getSlogan() {
return "jOOQ power users may want to fine-tune their source code generation settings. Here's how to do this";
}
function printContent() {
global $root;
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" align="left"><a href="<?=$root?>/manual/">The jOOQ User Manual</a> : <a href="<?=$root?>/manual/META/">Meta model code generation</a> : <a href="<?=$root?>/manual/META/AdvancedConfiguration/">Advanced configuration of the generator</a></td><td style="white-space: nowrap" valign="top" align="right"><a title="Previous section: Configuration and setup of the generator" href="<?=$root?>/manual/META/Configuration/">previous</a> : <a title="Next section: The schema, top-level generated artefact" href="<?=$root?>/manual/META/SCHEMA/">next</a></td>
</tr>
</table>
<h2>Code generation</h2>
<p>
In the <a href="<?=$root?>/manual/META/Configuration/" title="jOOQ Manual reference: Configuration and setup of the generator">previous section</a>
we have seen how jOOQ's source code generator is configured and
run within a few steps. In this chapter we'll treat some advanced
settings
</p>
<pre class="prettyprint lang-xml">&lt;!-- These properties can be added directly to the generator element: --&gt;
&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;
&lt;!-- The naming strategy used for class and field names.
You may override this with your custom naming strategy. Some examples follow
Defaults to org.jooq.util.DefaultGeneratorStrategy --&gt;
&lt;strategy&gt;
&lt;name&gt;org.jooq.util.DefaultGeneratorStrategy&lt;/name&gt;
&lt;/strategy&gt;
&lt;/generator&gt;</pre>
<p>
The following example shows how you can override the
DefaultGeneratorStrategy to render table and column names the way
they are defined in the database, rather than switching them to
camel case:
</p>
<pre class="prettyprint lang-java">/**
* It is recommended that you extend the DefaultGeneratorStrategy. Most of the
* GeneratorStrategy API is already declared final. You only need to override any
* of the following methods, for whatever generation behaviour you'd like to achieve
*
* Beware that most methods also receive a "Mode" object, to tell you whether a
* TableDefinition is being rendered as a Table, Record, POJO, etc. Depending on
* that information, you can add a suffix only for TableRecords, not for Tables
*/
public class AsInDatabaseStrategy extends DefaultGeneratorStrategy {
/**
* Override this to specifiy what identifiers in Java should look like.
* This will just take the identifier as defined in the database.
*/
@Override
public String getJavaIdentifier(Definition definition) {
return definition.getOutputName();
}
/**
* Override these to specify what a setter in Java should look like. Setters
* are used in TableRecords, UDTRecords, and POJOs. This example will name
* setters "set[NAME_IN_DATABASE]"
*/
@Override
public String getJavaSetterName(Definition definition, Mode mode) {
return "set" + definition.getOutputName();
}
/**
* Just like setters...
*/
@Override
public String getJavaGetterName(Definition definition, Mode mode) {
return "get" + definition.getOutputName();
}
/**
* Override this method to define what a Java method generated from a database
* Definition should look like. This is used mostly for convenience methods
* when calling stored procedures and functions. This example shows how to
* set a prefix to a CamelCase version of your procedure
*/
@Override
public String getJavaMethodName(Definition definition, Mode mode) {
return "call" + org.jooq.tools.StringUtils.toCamelCase(definition.getOutputName());
}
/**
* Override this method to define how your Java classes and Java files should
* be named. This example applies no custom setting and uses CamelCase versions
* instead
*/
@Override
public String getJavaClassName(Definition definition, Mode mode) {
return super.getJavaClassName(definition, mode);
}
/**
* Override this method to re-define the package names of your generated
* artefacts.
*/
@Override
public String getJavaPackageName(Definition definition, Mode mode) {
return super.getJavaPackageName(definition, mode);
}
/**
* Override this method to define how Java members should be named. This is
* used for POJOs and method arguments
*/
@Override
public String getJavaMemberName(Definition definition, Mode mode) {
return definition.getOutputName();
}
}</pre>
<p>
Within the &lt;generator/&gt; element, there are other configuration elements:
</p>
<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;
&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;
&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>
<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>
<br><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" align="left"><a href="<?=$root?>/manual/">The jOOQ User Manual</a> : <a href="<?=$root?>/manual/META/">Meta model code generation</a> : <a href="<?=$root?>/manual/META/AdvancedConfiguration/">Advanced configuration of the generator</a></td><td style="white-space: nowrap" valign="top" align="right"><a title="Previous section: Configuration and setup of the generator" href="<?=$root?>/manual/META/Configuration/">previous</a> : <a title="Next section: The schema, top-level generated artefact" href="<?=$root?>/manual/META/SCHEMA/">next</a></td>
</tr>
</table>
<?php
}
?>

View File

@ -17,7 +17,7 @@ function printContent() {
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" align="left"><a href="<?=$root?>/manual/">The jOOQ User Manual</a> : <a href="<?=$root?>/manual/META/">Meta model code generation</a> : <a href="<?=$root?>/manual/META/Configuration/">Configuration and setup of the generator</a></td><td style="white-space: nowrap" valign="top" align="right"><a title="Previous section: Meta model code generation" href="<?=$root?>/manual/META/">previous</a> : <a title="Next section: The schema, top-level generated artefact" href="<?=$root?>/manual/META/SCHEMA/">next</a></td>
<td valign="top" align="left"><a href="<?=$root?>/manual/">The jOOQ User Manual</a> : <a href="<?=$root?>/manual/META/">Meta model code generation</a> : <a href="<?=$root?>/manual/META/Configuration/">Configuration and setup of the generator</a></td><td style="white-space: nowrap" valign="top" align="right"><a title="Previous section: Meta model code generation" href="<?=$root?>/manual/META/">previous</a> : <a title="Next section: Advanced configuration of the generator" href="<?=$root?>/manual/META/AdvancedConfiguration/">next</a></td>
</tr>
</table>
<h2>The deliverables</h2>
@ -85,17 +85,6 @@ function printContent() {
&lt;/jdbc&gt;
&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;
&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;
&lt;database&gt;
&lt;!-- The database dialect from jooq-meta. Available dialects are
named org.util.[database].[database]Database. Known values are:
@ -151,97 +140,10 @@ function printContent() {
&lt;/generator&gt;
&lt;/configuration&gt;</pre>
<p>And you can add some optional advanced configuration parameters for the database: </p>
<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;
&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;
&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>
<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
<p>
There are also lots of advanced configuration parameters, which will be
treated in the <a href="<?=$root?>/manual/META/AdvancedConfiguration/" title="jOOQ Manual reference: Advanced configuration of the generator">manual's next section</a>
Note, you can find 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>
@ -424,7 +326,7 @@ function printContent() {
can execute SQL statements with your generated classes.</p>
<br><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" align="left"><a href="<?=$root?>/manual/">The jOOQ User Manual</a> : <a href="<?=$root?>/manual/META/">Meta model code generation</a> : <a href="<?=$root?>/manual/META/Configuration/">Configuration and setup of the generator</a></td><td style="white-space: nowrap" valign="top" align="right"><a title="Previous section: Meta model code generation" href="<?=$root?>/manual/META/">previous</a> : <a title="Next section: The schema, top-level generated artefact" href="<?=$root?>/manual/META/SCHEMA/">next</a></td>
<td valign="top" align="left"><a href="<?=$root?>/manual/">The jOOQ User Manual</a> : <a href="<?=$root?>/manual/META/">Meta model code generation</a> : <a href="<?=$root?>/manual/META/Configuration/">Configuration and setup of the generator</a></td><td style="white-space: nowrap" valign="top" align="right"><a title="Previous section: Meta model code generation" href="<?=$root?>/manual/META/">previous</a> : <a title="Next section: Advanced configuration of the generator" href="<?=$root?>/manual/META/AdvancedConfiguration/">next</a></td>
</tr>
</table>
<?php

View File

@ -19,7 +19,7 @@ function printContent() {
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" align="left"><a href="<?=$root?>/manual/">The jOOQ User Manual</a> : <a href="<?=$root?>/manual/META/">Meta model code generation</a> : <a href="<?=$root?>/manual/META/SCHEMA/">The schema, top-level generated artefact</a></td><td style="white-space: nowrap" valign="top" align="right"><a title="Previous section: Configuration and setup of the generator" href="<?=$root?>/manual/META/Configuration/">previous</a> : <a title="Next section: Tables, views and their corresponding records" href="<?=$root?>/manual/META/TABLE/">next</a></td>
<td valign="top" align="left"><a href="<?=$root?>/manual/">The jOOQ User Manual</a> : <a href="<?=$root?>/manual/META/">Meta model code generation</a> : <a href="<?=$root?>/manual/META/SCHEMA/">The schema, top-level generated artefact</a></td><td style="white-space: nowrap" valign="top" align="right"><a title="Previous section: Advanced configuration of the generator" href="<?=$root?>/manual/META/AdvancedConfiguration/">previous</a> : <a title="Next section: Tables, views and their corresponding records" href="<?=$root?>/manual/META/TABLE/">next</a></td>
</tr>
</table>
<h2>The Schema</h2>
@ -55,7 +55,7 @@ function printContent() {
public final java.util.List&lt;org.jooq.Table&lt;?&gt;&gt; getTables();</pre>
<br><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" align="left"><a href="<?=$root?>/manual/">The jOOQ User Manual</a> : <a href="<?=$root?>/manual/META/">Meta model code generation</a> : <a href="<?=$root?>/manual/META/SCHEMA/">The schema, top-level generated artefact</a></td><td style="white-space: nowrap" valign="top" align="right"><a title="Previous section: Configuration and setup of the generator" href="<?=$root?>/manual/META/Configuration/">previous</a> : <a title="Next section: Tables, views and their corresponding records" href="<?=$root?>/manual/META/TABLE/">next</a></td>
<td valign="top" align="left"><a href="<?=$root?>/manual/">The jOOQ User Manual</a> : <a href="<?=$root?>/manual/META/">Meta model code generation</a> : <a href="<?=$root?>/manual/META/SCHEMA/">The schema, top-level generated artefact</a></td><td style="white-space: nowrap" valign="top" align="right"><a title="Previous section: Advanced configuration of the generator" href="<?=$root?>/manual/META/AdvancedConfiguration/">previous</a> : <a title="Next section: Tables, views and their corresponding records" href="<?=$root?>/manual/META/TABLE/">next</a></td>
</tr>
</table>
<?php

View File

@ -47,6 +47,9 @@ function printContent() {
<a title="Configuration and setup of the generator" href="<?=$root?>/manual/META/Configuration/">Configuration and setup of the generator</a>
</li>
<li>
<a title="Advanced configuration of the generator" href="<?=$root?>/manual/META/AdvancedConfiguration/">Advanced configuration of the generator</a>
</li>
<li>
<a title="The schema, top-level generated artefact" href="<?=$root?>/manual/META/SCHEMA/">The schema, top-level generated artefact</a>
</li>
<li>

View File

@ -137,6 +137,9 @@ function printContent() {
<a title="Configuration and setup of the generator" href="<?=$root?>/manual/META/Configuration/">Configuration and setup of the generator</a>
</li>
<li>
<a title="Advanced configuration of the generator" href="<?=$root?>/manual/META/AdvancedConfiguration/">Advanced configuration of the generator</a>
</li>
<li>
<a title="The schema, top-level generated artefact" href="<?=$root?>/manual/META/SCHEMA/">The schema, top-level generated artefact</a>
</li>
<li>
@ -210,6 +213,9 @@ function printContent() {
<a title="Mapping generated schemata and tables" href="<?=$root?>/manual/ADVANCED/SchemaMapping/">Mapping generated schemata and tables</a>
</li>
<li>
<a title="Execute listeners and SQL tracing" href="<?=$root?>/manual/ADVANCED/ExecuteListener/">Execute listeners and SQL tracing</a>
</li>
<li>
<a title="Adding Oracle hints to queries" href="<?=$root?>/manual/ADVANCED/OracleHints/">Adding Oracle hints to queries</a>
</li>
<li>

View File

@ -173,15 +173,33 @@ CREATE TABLE t_book_to_book_store (
<li><reference class="java.sql.Connection"/> :
A JDBC Connection that will be re-used for the whole
lifecycle of your Factory</li>
<li><reference class="org.jooq.SchemaMapping"/> :
An optional mapping of schemata. Check out the
<reference id="SchemaMapping" title="SchemaMapping"/>
page for details</li>
<li><reference class="org.jooq.conf.Settings"/> :
An optional runtime configuration.</li>
</ul>
<p>If you are planning on using several RDBMS (= SQLDialects) or
several distinct JDBC Connections in your software, this will mean
that you have to create a new Factory every time. </p>
<h3>Factory settings</h3>
<p>
The jOOQ Factory allows for some optional configuration elements to be used by advanced users.
The <reference class="org.jooq.conf.Settings" title="Settings"/> class is a JAXB-annotated
type. In future releases of jOOQ, these settings can be loaded from an XML file automatically.
Subsequent sections of the manual contain some more in-depth explanations about these settings:
</p>
<ul>
<li>
<reference id="SchemaMapping" title="Runtime schema and table mapping"/>
</li>
<li>
<reference id="ExecuteListener" title="Execute listeners and SQL tracing"/>
</li>
</ul>
<p>
Please refer to the jOOQ runtime configuration XSD for more details:<br/>
<a href="http://www.jooq.org/xsd/jooq-runtime-2.0.5.xsd" title="The jOOQ Runtime configuration XSD">http://www.jooq.org/xsd/jooq-runtime-2.0.5.xsd</a>
</p>
<h3>Factory subclasses</h3>
<p>
There are a couple of subclasses for the general Factory. Each SQL
@ -1018,6 +1036,9 @@ Object[] fetchArray(String fieldName);
// Fetch a Cursor for lazy iteration
Cursor<R> fetchLazy();
// Or a JDBC ResultSet, if you prefer that
ResultSet fetchResultSet();
// Fetch data asynchronously and let client code
// decide, when the data must be available.
// This makes use of the java.util.concurrent API,
@ -1426,17 +1447,6 @@ public void bind(BindContext context) throws DataAccessException;</java>
</jdbc>
<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 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>
<database>
<!-- The database dialect from jooq-meta. Available dialects are
named org.util.[database].[database]Database. Known values are:
@ -1492,97 +1502,10 @@ public void bind(BindContext context) throws DataAccessException;</java>
</generator>
</configuration>]]></xml>
<p>And you can add some optional advanced configuration parameters for the database: </p>
<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 -->
<unsignedTypes>true</unsignedTypes>
<!-- 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>
<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
<p>
There are also lots of advanced configuration parameters, which will be
treated in the <reference id="AdvancedConfiguration" title="manual's next section"/>
Note, you can find 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>
@ -1753,6 +1676,214 @@ public void bind(BindContext context) throws DataAccessException;</java>
</section>
<section id="AdvancedConfiguration">
<title>Advanced configuration of the generator</title>
<slogan>jOOQ power users may want to fine-tune their source code generation settings. Here's how to do this</slogan>
<content>
<h2>Code generation</h2>
<p>
In the <reference id="Configuration" title="previous section"/>
we have seen how jOOQ's source code generator is configured and
run within a few steps. In this chapter we'll treat some advanced
settings
</p>
<xml><![CDATA[<!-- These properties can be added directly to the generator element: -->
<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 naming strategy used for class and field names.
You may override this with your custom naming strategy. Some examples follow
Defaults to org.jooq.util.DefaultGeneratorStrategy -->
<strategy>
<name>org.jooq.util.DefaultGeneratorStrategy</name>
</strategy>
</generator>]]></xml>
<p>
The following example shows how you can override the
DefaultGeneratorStrategy to render table and column names the way
they are defined in the database, rather than switching them to
camel case:
</p>
<java>/**
* It is recommended that you extend the DefaultGeneratorStrategy. Most of the
* GeneratorStrategy API is already declared final. You only need to override any
* of the following methods, for whatever generation behaviour you'd like to achieve
*
* Beware that most methods also receive a "Mode" object, to tell you whether a
* TableDefinition is being rendered as a Table, Record, POJO, etc. Depending on
* that information, you can add a suffix only for TableRecords, not for Tables
*/
public class AsInDatabaseStrategy extends DefaultGeneratorStrategy {
/**
* Override this to specifiy what identifiers in Java should look like.
* This will just take the identifier as defined in the database.
*/
@Override
public String getJavaIdentifier(Definition definition) {
return definition.getOutputName();
}
/**
* Override these to specify what a setter in Java should look like. Setters
* are used in TableRecords, UDTRecords, and POJOs. This example will name
* setters "set[NAME_IN_DATABASE]"
*/
@Override
public String getJavaSetterName(Definition definition, Mode mode) {
return "set" + definition.getOutputName();
}
/**
* Just like setters...
*/
@Override
public String getJavaGetterName(Definition definition, Mode mode) {
return "get" + definition.getOutputName();
}
/**
* Override this method to define what a Java method generated from a database
* Definition should look like. This is used mostly for convenience methods
* when calling stored procedures and functions. This example shows how to
* set a prefix to a CamelCase version of your procedure
*/
@Override
public String getJavaMethodName(Definition definition, Mode mode) {
return "call" + org.jooq.tools.StringUtils.toCamelCase(definition.getOutputName());
}
/**
* Override this method to define how your Java classes and Java files should
* be named. This example applies no custom setting and uses CamelCase versions
* instead
*/
@Override
public String getJavaClassName(Definition definition, Mode mode) {
return super.getJavaClassName(definition, mode);
}
/**
* Override this method to re-define the package names of your generated
* artefacts.
*/
@Override
public String getJavaPackageName(Definition definition, Mode mode) {
return super.getJavaPackageName(definition, mode);
}
/**
* Override this method to define how Java members should be named. This is
* used for POJOs and method arguments
*/
@Override
public String getJavaMemberName(Definition definition, Mode mode) {
return definition.getOutputName();
}
}</java>
<p>
Within the &lt;generator/&gt; element, there are other configuration elements:
</p>
<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 -->
<unsignedTypes>true</unsignedTypes>
<!-- 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>
<p>
Check out the manual's section about
<reference id="MasterData" title="master data"/>
to find out more
about those advanced configuration parameters.
</p>
</content>
</section>
<section id="SCHEMA">
<title>The schema, top-level generated artefact</title>
<slogan>The schema is the top-level generated object in jOOQ. In many
@ -2826,6 +2957,8 @@ TableOnConditionStep onKey(ForeignKey<?, ?> key);]]></java>
Condition notIn(Select<?> query);
Condition in(Collection<T> values);
Condition between(T minValue, T maxValue);
Condition contains(T value);
Condition contains(Field<T> value);
Condition equal(T value);
Condition equal(Field<T> field);
Condition equal(Select<?> query);
@ -2835,6 +2968,8 @@ TableOnConditionStep onKey(ForeignKey<?, ?> key);]]></java>
Condition equalAll(Select<?> query);
Condition equalAll(T... array);
Condition equalAll(Field<T[]> array);
Condition equalIgnoreCase(String value);
Condition equalIgnoreCase(Field<String> value);
Condition notEqual(T value);
Condition notEqual(Field<T> field);
Condition notEqual(Select<?> query);
@ -3936,15 +4071,18 @@ create.select(LAST_NAME, COUNT1, COUNT2)
<p>When a user from My Book World logs in, you want them to access the
MY_BOOK_WORLD schema using classes generated from DEV. This can be
achieved with the
<reference class="org.jooq.SchemaMapping"/>
class, that you can equip your Factory
<reference class="org.jooq.conf.RenderMapping"/>
class, that you can equip your Factory's settings
with. Take the following example: </p>
<java>SchemaMapping mapping = new SchemaMapping();
mapping.add(DEV, "MY_BOOK_WORLD");
<java>Settings settings = new Settings()
.withRenderMapping(new RenderMapping()
.withSchemata(
new MappedSchema().withInput("DEV")
.withOutput("MY_BOOK_WORLD")));
// Add the mapping to the factory
Factory create = new Factory(connection, SQLDialect.ORACLE, mapping);
// Add the settings to the factory
Factory create = new Factory(connection, SQLDialect.ORACLE, settings);
// Run queries with the "mapped" factory
create.selectFrom(T_AUTHOR).fetch();</java>
@ -3958,12 +4096,27 @@ create.selectFrom(T_AUTHOR).fetch();</java>
<p>Your development database may not be restricted to hold only one DEV
schema. You may also have a LOG schema and a MASTER schema. Let's say
the MASTER schema is shared among all customers, but each customer has
their own LOG schema instance. Then you can enhance your SchemaMapping
like this: </p>
their own LOG schema instance. Then you can enhance your RenderMapping
like this (e.g. using an XML configuration file): </p>
<java>SchemaMapping mapping = new SchemaMapping();
mapping.add(DEV, "MY_BOOK_WORLD");
mapping.add(LOG, "MY_BOOK_WORLD_LOG");</java>
<xml><![CDATA[<settings xmlns="http://www.jooq.org/xsd/jooq-runtime-2.0.5.xsd">
<renderMapping>
<schemata>
<schema>
<input>DEV</input>
<output>MY_BOOK_WORLD</output>
</schema>
<schema>
<input>LOG</input>
<output>MY_BOOK_WORLD_LOG</output>
</schema>
</schemata>
</renderMapping>
</settings>]]></xml>
<p>Note, you can load the above XML file like this:</p>
<java>Settings settings = JAXB.unmarshal(new File("jooq-runtime.xml"), Settings.class);</java>
<p>This will map generated classes from DEV to MY_BOOK_WORLD, from LOG
to MY_BOOK_WORLD_LOG, but leave the MASTER schema alone. Whenever you
@ -3997,12 +4150,17 @@ SELECT * FROM T_AUTHOR</sql>
applied to all of your tables. This can be achieved by creating the
following mapping: </p>
<java>SchemaMapping mapping = new SchemaMapping();
mapping.add(DEV, "MY_BOOK_WORLD");
mapping.add(T_AUTHOR, "MY_APP__T_AUTHOR");
<java>Settings settings = new Settings()
.withRenderMapping(new RenderMapping()
.withSchemata(
new MappedSchema().withInput("DEV")
.withOutput("MY_BOOK_WORLD")
.withTables(
new MappedTable().withInput("T_AUTHOR")
.withOutput("MY_APP__T_AUTHOR"))));
// Add the mapping to the factory
Factory create = new Factory(connection, SQLDialect.ORACLE, mapping);
// Add the settings to the factory
Factory create = new Factory(connection, SQLDialect.ORACLE, settings);
// Run queries with the "mapped" factory
create.selectFrom(T_AUTHOR).fetch();</java>
@ -4035,6 +4193,70 @@ create.selectFrom(T_AUTHOR).fetch();</java>
</section>
<section id="ExecuteListener">
<title>Execute listeners and SQL tracing</title>
<slogan>
Feel the heart beat of your SQL statements at a very low level using listeners
</slogan>
<content>
<h2>ExecuteListener</h2>
<p>
The <reference id="Factory" title="jOOQ Factory Settings"/>
let you specify a list of <reference class="org.jooq.ExecuteListener"/> classes.
The ExecuteListener is essentially an event listener for
Query, Routine, or ResultSet render, prepare, bind, execute, fetch steps. It is a
base type for loggers, debuggers, profilers, data collectors. Advanced ExecuteListeners
can also provide custom implementations of Connection, PreparedStatement and ResultSet
to jOOQ in apropriate methods. For convenience, consider extending
<reference class="org.jooq.impl.DefaultExecuteListener"/>
instead of implementing this interface. Please read the
<a href="www.jooq.org/javadoc/latest/org/jooq/ExecuteListener.html" title="ExecuteListener Javadoc">ExecuteListener Javadoc</a>
for more details
</p>
<h2>jOOQ Console</h2>
<p>
The ExecuteListener API was driven by a feature request by Christopher Deckers, who has
had the courtesy to contribute the jOOQ Console, a sample application interfacing
with jOOQ's ExecuteListeners. Please note that the jOOQ Console is still experimental.
Any feedback is very welcome on
<a href="http://groups.google.com/group/jooq-user" title="the jooq-user group">the jooq-user group</a>
</p>
<p>
Here are the steps you need to do to run the console
</p>
<java>// Create a new RemoteDebuggerServer in your application that listens to
// incoming connections on a given port
SERVER = new RemoteDebuggerServer(DEBUGGER_PORT);</java>
<p>
And configure the <reference class="org.jooq.debug.DebugListener"/> in the
Factory's settings:
</p>
<xml><![CDATA[<settings>
<executeListeners>
<executeListener>org.jooq.debug.DebugListener</executeListener>
</executeListeners>
</settings>]]></xml>
<p>
Now start your application and the
<reference class="org.jooq.debug.console.Console"/>, and start profiling!
</p>
<div class="screenshot">
<img class="screenshot" src="&lt;?=$root?&gt;/img/jooq-console-01.png" alt="jOOQ Console example"/>
</div>
<p>
The jOOQ Console also has other modes of execution, which will be documented here
soon.
</p>
</content>
</section>
<section id="OracleHints">
<title>Adding Oracle hints to queries</title>
<slogan>