public interface Configuration
extends java.io.Serializable
Configuration
configures a DSLContext
, providing it
with information for query rendering and execution.
A Configuration
wraps all information elements that are
needed...
RenderContext
to render Query
objects and
QueryPart
sBindContext
to bind values to Query
objects and
QueryPart
sQuery
or Routine
object to execute themselves
The simplest usage of a Configuration
instance is to use it
exactly for a single Query
execution, disposing it immediately.
This will make it very simple to implement thread-safe behaviour.
At the same time, jOOQ does not require Configuration
instances
to be that short-lived. Thread-safety will then be delegated to component
objects, such as the ConnectionProvider
, the ExecuteListener
list, etc.
A Configuration
is composed of types composing its state and of
SPIs:
dialect()
: The SQLDialect
that defines the underlying
database's behaviour when generating SQL syntax, or bind variables, or
when executing the querysettings()
: The Settings
that define general jOOQ
behaviourdata()
: A Map
containing user-defined data for the
Scope
of this configuration.connectionProvider()
: The ConnectionProvider
that
defines the semantics of ConnectionProvider.acquire()
and
ConnectionProvider.release(Connection)
for all queries executed in
the context of this Configuration
. DefaultConnectionProvider
: a non-thread-safe implementation that
wraps a single JDBC Connection
. Ideal for batch processing.DataSourceConnectionProvider
: a possibly thread-safe
implementation that wraps a JDBC DataSource
. Ideal for use with
connection pools, Java EE, or Spring.transactionProvider()
: The TransactionProvider
that
defines and implements the behaviour of the
DSLContext.transaction(TransactionalRunnable)
and
DSLContext.transactionResult(TransactionalCallable)
methods.DefaultTransactionProvider
: an implementation backed by JDBC
directly, via Connection.commit()
, Connection.rollback()
, and
Connection.rollback(Savepoint)
for nested transactions.recordMapperProvider()
: The RecordMapperProvider
that
defines and implements the behaviour of Record.into(Class)
,
ResultQuery.fetchInto(Class)
, Cursor.fetchInto(Class)
, and
various related methods. DefaultRecordMapperProvider
: an implementation delegating to the
DefaultRecordMapper
, which implements the most common mapping
use-cases.recordListenerProviders()
: A set of
RecordListenerProvider
that implement Record
fetching and
storing lifecycle management, specifically for use with
UpdatableRecord
.executeListenerProviders()
: A set of
ExecuteListenerProvider
that implement Query
execution
lifecycle management.LoggerListener
: generating default query execution log output
(active by default)StopWatchListener
: generating default query execution speed log
output (inactive by default)visitListenerProviders()
: A set of VisitListenerProvider
that implement Query
rendering and variable binding lifecycle
management, and that are allowed to implement query transformation - e.g. to
implement row-level security, or multi-tenancy.Modifier and Type | Method and Description |
---|---|
java.time.Clock |
clock()
Get this configuration's
Clock , which is used for optimistic
locking, transaction time, and other time-depending features. |
ConnectionProvider |
connectionProvider()
Get this configuration's underlying connection provider.
|
ConverterProvider |
converterProvider()
Deprecated.
- This API is still EXPERIMENTAL. Do not use yet
|
java.util.Map<java.lang.Object,java.lang.Object> |
data()
Get all custom data from this
Configuration . |
java.lang.Object |
data(java.lang.Object key)
Get some custom data from this
Configuration . |
java.lang.Object |
data(java.lang.Object key,
java.lang.Object value)
Set some custom data to this
Configuration . |
Configuration |
derive()
Create a derived configuration from this one, without changing any
properties.
|
Configuration |
derive(java.time.Clock newClock)
Create a derived configuration from this one, with a new
Clock . |
Configuration |
derive(java.sql.Connection newConnection)
Create a derived configuration from this one, with a new connection
wrapped in a
DefaultConnectionProvider . |
Configuration |
derive(ConnectionProvider newConnectionProvider)
Create a derived configuration from this one, with a new connection
provider.
|
Configuration |
derive(ConverterProvider newConverterProvider)
Deprecated.
- This API is still EXPERIMENTAL. Do not use yet
|
Configuration |
derive(javax.sql.DataSource newDataSource)
Create a derived configuration from this one, with a new data source
wrapped in a
DataSourceConnectionProvider . |
Configuration |
derive(ExecuteListener... newExecuteListeners)
Create a derived configuration from this one, with new execute listeners.
|
Configuration |
derive(ExecuteListenerProvider... newExecuteListenerProviders)
Create a derived configuration from this one, with new execute listener
providers.
|
Configuration |
derive(java.util.concurrent.Executor newExecutor)
Create a derived configuration from this one, with a new executor.
|
Configuration |
derive(ExecutorProvider newExecutorProvider)
Create a derived configuration from this one, with a new executor
provider.
|
Configuration |
derive(RecordListener... newRecordListeners)
Create a derived configuration from this one, with new record listeners.
|
Configuration |
derive(RecordListenerProvider... newRecordListenerProviders)
Create a derived configuration from this one, with new record listener
providers.
|
Configuration |
derive(RecordMapper<?,?> newRecordMapper)
Create a derived configuration from this one, with a new record mapper.
|
Configuration |
derive(RecordMapperProvider newRecordMapperProvider)
Create a derived configuration from this one, with a new record mapper
provider.
|
Configuration |
derive(RecordUnmapper<?,?> newRecordUnmapper)
Create a derived configuration from this one, with a new record unmapper.
|
Configuration |
derive(RecordUnmapperProvider newRecordUnmapperProvider)
Create a derived configuration from this one, with a new record unmapper
provider.
|
Configuration |
derive(Settings newSettings)
Create a derived configuration from this one, with new settings.
|
Configuration |
derive(SQLDialect newDialect)
Create a derived configuration from this one, with a new dialect.
|
Configuration |
derive(TransactionListener... newTransactionListeners)
Create a derived configuration from this one, with new transaction
listeners.
|
Configuration |
derive(TransactionListenerProvider... newTransactionListenerProviders)
Create a derived configuration from this one, with new transaction
listener providers.
|
Configuration |
derive(TransactionProvider newTransactionProvider)
Create a derived configuration from this one, with a new transaction
provider.
|
Configuration |
derive(VisitListener... newVisitListeners)
Create a derived configuration from this one, with new visit listeners.
|
Configuration |
derive(VisitListenerProvider... newVisitListenerProviders)
Create a derived configuration from this one, with new visit listener
providers.
|
SQLDialect |
dialect()
Retrieve the configured dialect.
|
DSLContext |
dsl()
Wrap this
Configuration in a DSLContext , providing
access to the configuration-contextual DSL to construct executable
queries. |
ExecuteListenerProvider[] |
executeListenerProviders()
Get the configured
ExecuteListenerProvider s from this
configuration. |
ExecutorProvider |
executorProvider()
Get this configuration's underlying executor provider.
|
SQLDialect |
family()
Retrieve the family of the configured dialect.
|
RecordListenerProvider[] |
recordListenerProviders()
Get the configured
RecordListenerProvider s from this
configuration. |
RecordMapperProvider |
recordMapperProvider()
Get this configuration's underlying record mapper provider.
|
RecordUnmapperProvider |
recordUnmapperProvider()
Get this configuration's underlying record unmapper provider.
|
SchemaMapping |
schemaMapping()
Deprecated.
- 2.0.5 - Use
settings() instead |
Configuration |
set(java.time.Clock newClock)
Change this configuration to hold a new
Clock . |
Configuration |
set(java.sql.Connection newConnection)
Change this configuration to hold a new connection wrapped in a
DefaultConnectionProvider . |
Configuration |
set(ConnectionProvider newConnectionProvider)
Change this configuration to hold a new connection provider.
|
Configuration |
set(ConverterProvider newConverterProvider)
Deprecated.
- This API is still EXPERIMENTAL. Do not use yet
|
Configuration |
set(javax.sql.DataSource newDataSource)
Change this configuration to hold a new data source wrapped in a
DataSourceConnectionProvider . |
Configuration |
set(ExecuteListener... newExecuteListeners)
Change this configuration to hold a new execute listeners.
|
Configuration |
set(ExecuteListenerProvider... newExecuteListenerProviders)
Change this configuration to hold a new execute listener providers.
|
Configuration |
set(java.util.concurrent.Executor newExecutor)
Change this configuration to hold a new executor.
|
Configuration |
set(ExecutorProvider newExecutorProvider)
Change this configuration to hold a new executor provider.
|
Configuration |
set(RecordListener... newRecordListeners)
Change this configuration to hold a new record listeners.
|
Configuration |
set(RecordListenerProvider... newRecordListenerProviders)
Change this configuration to hold a new record listener providers.
|
Configuration |
set(RecordMapper<?,?> newRecordMapper)
Change this configuration to hold a new record mapper.
|
Configuration |
set(RecordMapperProvider newRecordMapperProvider)
Change this configuration to hold a new record mapper provider.
|
Configuration |
set(RecordUnmapper<?,?> newRecordUnmapper)
Change this configuration to hold a new record unmapper.
|
Configuration |
set(RecordUnmapperProvider newRecordUnmapperProvider)
Change this configuration to hold a new record unmapper provider.
|
Configuration |
set(Settings newSettings)
Change this configuration to hold a new settings.
|
Configuration |
set(SQLDialect newDialect)
Change this configuration to hold a new dialect.
|
Configuration |
set(TransactionListener... newTransactionListeners)
Change this configuration to hold a new transaction listeners.
|
Configuration |
set(TransactionListenerProvider... newTransactionListenerProviders)
Change this configuration to hold a new transaction listener providers.
|
Configuration |
set(TransactionProvider newTransactionProvider)
Change this configuration to hold a new transaction provider.
|
Configuration |
set(VisitListener... newVisitListeners)
Change this configuration to hold a new visit listeners.
|
Configuration |
set(VisitListenerProvider... newVisitListenerProviders)
Change this configuration to hold a new visit listener providers.
|
Settings |
settings()
Retrieve the runtime configuration settings.
|
TransactionListenerProvider[] |
transactionListenerProviders()
Get the configured
TransactionListenerProvider s from this
configuration. |
TransactionProvider |
transactionProvider()
Get this configuration's underlying transaction provider.
|
VisitListenerProvider[] |
visitListenerProviders()
TODO [#2667]
|
DSLContext dsl()
Configuration
in a DSLContext
, providing
access to the configuration-contextual DSL to construct executable
queries.java.util.Map<java.lang.Object,java.lang.Object> data()
Configuration
.
This is custom data that was previously set to the configuration using
data(Object, Object)
. Use custom data if you want to pass data
to your custom QueryPart
or ExecuteListener
objects to be
made available at render, bind, execution, fetch time.
See ExecuteListener
for more details.
null
ExecuteListener
java.lang.Object data(java.lang.Object key)
Configuration
.
This is custom data that was previously set to the configuration using
data(Object, Object)
. Use custom data if you want to pass data
to your custom QueryPart
or ExecuteListener
objects to be
made available at render, bind, execution, fetch time.
See ExecuteListener
for more details.
key
- A key to identify the custom datanull
if no such data is contained
in this Configuration
ExecuteListener
java.lang.Object data(java.lang.Object key, java.lang.Object value)
Configuration
.
Use custom data if you want to pass data to your custom QueryPart
or ExecuteListener
objects to be made available at render, bind,
execution, fetch time.
Be sure that your custom data implements Serializable
if you want
to serialise this Configuration
or objects referencing this
Configuration
, e.g. your Record
types.
See ExecuteListener
for more details.
key
- A key to identify the custom datavalue
- The custom datanull
if no data
was previously set for the given keyExecuteListener
java.time.Clock clock()
Clock
, which is used for optimistic
locking, transaction time, and other time-depending features.ConnectionProvider connectionProvider()
ExecutorProvider executorProvider()
Asynchronous operations will call back to this SPI to obtain an executor.
This applies, for example, to ResultQuery.fetchAsync()
.
The following logic is applied when resolving the appropriate
executor
:
executorProvider()
does not return
null
, then ExecutorProvider.provide()
is called to
obtain an Executor
for the asynchronous task.ForkJoinPool.commonPool()
is
used if ForkJoinPool.getCommonPoolParallelism()
> 1
Executor
is used in any
other case.
The SPI will not be called if an asynchronous operation explicitly
overrides the Executor
, e.g. as is the case for
ResultQuery.fetchAsync(Executor)
.
TransactionProvider transactionProvider()
If no explicit transaction provider was specified, and if
connectionProvider()
is a DefaultConnectionProvider
,
then this will return a DefaultTransactionProvider
.
TransactionListenerProvider[] transactionListenerProviders()
TransactionListenerProvider
s from this
configuration.RecordMapperProvider recordMapperProvider()
RecordUnmapperProvider recordUnmapperProvider()
RecordListenerProvider[] recordListenerProviders()
RecordListenerProvider
s from this
configuration.
This method allows for retrieving the configured
RecordListenerProvider
from this configuration. The
providers will provide jOOQ with RecordListener
instances. These
instances receive record manipulation notification events every time jOOQ
executes queries. jOOQ makes no assumptions about the internal state of
these listeners, i.e. listener instances may
Configuration
's lifecycle (i.e. that of a
JDBC Connection
, or that of a transaction)RecordContext
(i.e. that of a
single record manipulation)RecordListenerProvider
,
RecordListener
,
RecordContext
ExecuteListenerProvider[] executeListenerProviders()
ExecuteListenerProvider
s from this
configuration.
This method allows for retrieving the configured
ExecuteListenerProvider
from this configuration. The
providers will provide jOOQ with ExecuteListener
instances. These
instances receive execution lifecycle notification events every time jOOQ
executes queries. jOOQ makes no assumptions about the internal state of
these listeners, i.e. listener instances may
Configuration
's lifecycle (i.e. that of a
JDBC Connection
, or that of a transaction)ExecuteContext
(i.e. that of a
single query execution)
Note, depending on your Settings.isExecuteLogging()
, some
additional listeners may be prepended to this list, internally. Those
listeners will never be exposed through this method, though.
ExecuteListenerProvider
,
ExecuteListener
,
ExecuteContext
VisitListenerProvider[] visitListenerProviders()
@Deprecated ConverterProvider converterProvider()
ConverterProvider
from this
configuration.@Deprecated SchemaMapping schemaMapping()
settings()
insteadSQLDialect dialect()
SQLDialect family()
Settings settings()
Configuration set(java.time.Clock newClock)
Clock
.
This method is not thread-safe and should not be used in globally
available Configuration
objects.
newClock
- The new clock to be contained in the changed
configuration.Configuration set(ConnectionProvider newConnectionProvider)
This method is not thread-safe and should not be used in globally
available Configuration
objects.
newConnectionProvider
- The new connection provider to be contained
in the changed configuration.Configuration set(ExecutorProvider newExecutorProvider)
This method is not thread-safe and should not be used in globally
available Configuration
objects.
newExecutorProvider
- The new executor provider to be contained in
the changed configuration.Configuration set(java.util.concurrent.Executor newExecutor)
This will wrap the argument Executor
in a
DefaultExecutorProvider
for convenience.
This method is not thread-safe and should not be used in globally
available Configuration
objects.
newExecutor
- The new executor to be contained in the changed
configuration.Configuration set(java.sql.Connection newConnection)
DefaultConnectionProvider
.
This method is not thread-safe and should not be used in globally
available Configuration
objects.
newConnection
- The new connection to be contained in the changed
configuration.Configuration set(javax.sql.DataSource newDataSource)
DataSourceConnectionProvider
.
This method is not thread-safe and should not be used in globally
available Configuration
objects.
newDataSource
- The new data source to be contained in the changed
configuration.Configuration set(TransactionProvider newTransactionProvider)
This method is not thread-safe and should not be used in globally
available Configuration
objects.
newTransactionProvider
- The new transaction provider to be
contained in the changed configuration.Configuration set(RecordMapper<?,?> newRecordMapper)
This will wrap the argument RecordMapper
in a
DefaultRecordMapperProvider
for convenience.
This method is not thread-safe and should not be used in globally
available Configuration
objects.
newRecordMapper
- The new record mapper to be contained in the
changed configuration.Configuration set(RecordMapperProvider newRecordMapperProvider)
This method is not thread-safe and should not be used in globally
available Configuration
objects.
newRecordMapperProvider
- The new record mapper provider to be
contained in the changed configuration.Configuration set(RecordUnmapper<?,?> newRecordUnmapper)
This will wrap the argument RecordUnmapper
in a
DefaultRecordUnmapperProvider
for convenience.
This method is not thread-safe and should not be used in globally
available Configuration
objects.
newRecordUnmapper
- The new record unmapper to be contained in the
changed configuration.Configuration set(RecordUnmapperProvider newRecordUnmapperProvider)
This method is not thread-safe and should not be used in globally
available Configuration
objects.
newRecordUnmapperProvider
- The new record unmapper provider to be
contained in the changed configuration.Configuration set(RecordListener... newRecordListeners)
This will wrap the argument RecordListener
in a
DefaultRecordListenerProvider
for convenience.
This method is not thread-safe and should not be used in globally
available Configuration
objects.
newRecordListeners
- The new record listener to be contained
in the changed configuration.Configuration set(RecordListenerProvider... newRecordListenerProviders)
This method is not thread-safe and should not be used in globally
available Configuration
objects.
newRecordListenerProviders
- The new record listener providers to
be contained in the changed configuration.Configuration set(ExecuteListener... newExecuteListeners)
This will wrap the argument ExecuteListener
in a
DefaultExecuteListenerProvider
for convenience.
This method is not thread-safe and should not be used in globally
available Configuration
objects.
newExecuteListeners
- The new execute listeners to be contained in
the changed configuration.Configuration set(ExecuteListenerProvider... newExecuteListenerProviders)
This method is not thread-safe and should not be used in globally
available Configuration
objects.
newExecuteListenerProviders
- The new execute listener providers to
be contained in the changed configuration.Configuration set(VisitListener... newVisitListeners)
This will wrap the argument VisitListener
in a
DefaultVisitListenerProvider
for convenience.
This method is not thread-safe and should not be used in globally
available Configuration
objects.
newVisitListeners
- The new visit listeners to be contained
in the changed configuration.Configuration set(VisitListenerProvider... newVisitListenerProviders)
This method is not thread-safe and should not be used in globally
available Configuration
objects.
newVisitListenerProviders
- The new visit listener providers to
be contained in the changed configuration.Configuration set(TransactionListener... newTransactionListeners)
This will wrap the argument TransactionListener
in a
DefaultTransactionListenerProvider
for convenience.
This method is not thread-safe and should not be used in globally
available Configuration
objects.
newTransactionListeners
- The new transaction listeners to be
contained in the changed configuration.Configuration set(TransactionListenerProvider... newTransactionListenerProviders)
This method is not thread-safe and should not be used in globally
available Configuration
objects.
newTransactionListenerProviders
- The new transaction listener
providers to be contained in the changed configuration.@Deprecated Configuration set(ConverterProvider newConverterProvider)
This method is not thread-safe and should not be used in globally
available Configuration
objects.
newConverterProvider
- The new converter provider to be contained in
the changed configuration.Configuration set(SQLDialect newDialect)
This method is not thread-safe and should not be used in globally
available Configuration
objects.
newDialect
- The new dialect to be contained in the changed
configuration.Configuration set(Settings newSettings)
This method is not thread-safe and should not be used in globally
available Configuration
objects.
newSettings
- The new settings to be contained in the changed
configuration.Configuration derive()
Configuration derive(java.time.Clock newClock)
Clock
.newClock
- The new clock to be contained in the derived
configuration.Configuration derive(java.sql.Connection newConnection)
DefaultConnectionProvider
.newConnection
- The new connection to be contained in the derived
configuration.Configuration derive(javax.sql.DataSource newDataSource)
DataSourceConnectionProvider
.newDataSource
- The new data source to be contained in the derived
configuration.Configuration derive(ConnectionProvider newConnectionProvider)
newConnectionProvider
- The new connection provider to be contained
in the derived configuration.Configuration derive(java.util.concurrent.Executor newExecutor)
This will wrap the argument Executor
in a
DefaultExecutorProvider
for convenience.
newExecutor
- The new executor to be contained in the derived
configuration.Configuration derive(ExecutorProvider newExecutorProvider)
newExecutorProvider
- The new executor provider to be contained in
the derived configuration.Configuration derive(TransactionProvider newTransactionProvider)
newTransactionProvider
- The new transaction provider to be
contained in the derived configuration.Configuration derive(RecordMapper<?,?> newRecordMapper)
This will wrap the argument RecordMapper
in a
DefaultRecordMapperProvider
for convenience.
newRecordMapper
- The new record mapper to be contained in the
derived configuration.Configuration derive(RecordMapperProvider newRecordMapperProvider)
newRecordMapperProvider
- The new record mapper provider to be
contained in the derived configuration.Configuration derive(RecordUnmapper<?,?> newRecordUnmapper)
This will wrap the argument RecordUnmapper
in a
DefaultRecordUnmapperProvider
for convenience.
newRecordUnmapper
- The new record unmapper to be contained in the
derived configuration.Configuration derive(RecordUnmapperProvider newRecordUnmapperProvider)
newRecordUnmapperProvider
- The new record unmapper provider to be
contained in the derived configuration.Configuration derive(RecordListener... newRecordListeners)
This will wrap the argument RecordListener
in a
DefaultRecordListenerProvider
for convenience.
newRecordListeners
- The new record listeners to be contained in the
derived configuration.Configuration derive(RecordListenerProvider... newRecordListenerProviders)
newRecordListenerProviders
- The new record listener providers to
be contained in the derived configuration.Configuration derive(ExecuteListener... newExecuteListeners)
This will wrap the argument ExecuteListener
in a
DefaultExecuteListenerProvider
for convenience.
newExecuteListeners
- The new execute listener to be contained in
the derived configuration.Configuration derive(ExecuteListenerProvider... newExecuteListenerProviders)
newExecuteListenerProviders
- The new execute listener providers to
be contained in the derived configuration.Configuration derive(VisitListener... newVisitListeners)
This will wrap the argument VisitListener
in a
DefaultVisitListenerProvider
for convenience.
newVisitListeners
- The new visit listeners to be contained in the
derived configuration.Configuration derive(VisitListenerProvider... newVisitListenerProviders)
newVisitListenerProviders
- The new visit listener providers to
be contained in the derived configuration.Configuration derive(TransactionListener... newTransactionListeners)
This will wrap the argument TransactionListener
in a
DefaultTransactionListenerProvider
for convenience.
newTransactionListeners
- The new transaction listeners to be
contained in the derived configuration.Configuration derive(TransactionListenerProvider... newTransactionListenerProviders)
newTransactionListenerProviders
- The new transaction listener
providers to be contained in the derived configuration.@Deprecated Configuration derive(ConverterProvider newConverterProvider)
newConverterProvider
- The new converter provider to be contained in
the derived configuration.Configuration derive(SQLDialect newDialect)
newDialect
- The new dialect to be contained in the derived
configuration.Configuration derive(Settings newSettings)
newSettings
- The new settings to be contained in the derived
configuration.Copyright © 2018. All Rights Reserved.