Available in versions: Dev (3.20) | Latest (3.19) | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11 | 3.10

This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.

The DSLContext API

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

DSLContext references a org.jooq.Configuration, an object that configures jOOQ's behaviour when executing queries (see SQL execution for more details). Unlike the static DSL, the DSLContext allow for creating SQL statements that are already "configured" and ready for execution.

Fluent creation of a DSLContext object

The DSLContext object can be created fluently from the DSL type:

// Create it from a pre-existing configuration
DSLContext create = DSL.using(configuration);

// Create it from ad-hoc arguments
DSLContext create = DSL.using(connection, dialect);

If you do not have a reference to a pre-existing Configuration object (e.g. created from org.jooq.impl.DefaultConfiguration), the various overloaded DSL.using() methods will create one for you.

Contents of a Configuration object

A Configuration can be supplied with these objects:

Usage of DSLContext

Wrapping a Configuration object, a DSLContext can construct statements, for later execution. An example is given here:

// The DSLContext is "configured" with a Connection and a SQLDialect
DSLContext create = DSL.using(connection, dialect);

// This select statement contains an internal reference to the DSLContext's Configuration:
Select<?> select = create.selectOne();

// Using the internally referenced Configuration, the select statement can now be executed:
Result<?> result = select.fetch();

Note that you do not need to keep a reference to a DSLContext. You may as well inline your local variable, and fluently execute a SQL statement as such:

// Execute a statement from a single execution chain:
Result<?> result =
DSL.using(connection, dialect)
   .select()
   .from(BOOK)
   .where(BOOK.TITLE.like("Animal%"))
   .fetch();

Table of contents

4.2.1.
SQL Dialect
4.2.2.
SQL Dialect Family
4.2.3.
SQL Dialect Category
4.2.4.
Connection vs. DataSource
4.2.5.
Custom data
4.2.6.
Custom ExecuteListeners
4.2.7.
Custom Unwrappers
4.2.8.
Custom Settings
4.2.8.1.
Auto-attach Records
4.2.8.2.
Auto-inline bind values
4.2.8.3.
Backslash Escaping
4.2.8.4.
Batch size
4.2.8.5.
Computed column emulation
4.2.8.6.
Diagnostics Connection
4.2.8.7.
Diagnostics Logging
4.2.8.8.
Dollar quoted string token
4.2.8.9.
Execute Logging
4.2.8.10.
Execute Logging SQL Exceptions
4.2.8.11.
Fetch Warnings
4.2.8.12.
GROUP_CONCAT Configuration
4.2.8.13.
Identifier style
4.2.8.14.
Implicit join type
4.2.8.15.
Inline Threshold
4.2.8.16.
IN-list Padding
4.2.8.17.
Interpreter Configuration
4.2.8.18.
JDBC Flags
4.2.8.19.
Keyword style
4.2.8.20.
Listener Invocation Order
4.2.8.21.
Locales
4.2.8.22.
Map JPA Annotations
4.2.8.23.
Object qualification
4.2.8.24.
Object qualification for columns
4.2.8.25.
Optimistic Locking
4.2.8.26.
Parameter name prefix
4.2.8.27.
Parameter types
4.2.8.28.
Parser Configuration
4.2.8.29.
Reflection caching
4.2.8.30.
Return all columns on store
4.2.8.31.
Return computed columns on store
4.2.8.32.
Return DEFAULT columns on store
4.2.8.33.
Return Identity Value On Store
4.2.8.34.
Runtime catalog, schema and table mapping
4.2.8.35.
Scalar subqueries for stored functions
4.2.8.36.
SEEK clause implementation
4.2.8.37.
Statement Type
4.2.8.38.
Updatable Primary Keys
4.2.9.
Thread safety

previous : next

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo