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 binding 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 outputStopWatchListener
: generating default query execution speed log
outputvisitListenerProviders()
: 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 |
---|---|
ConnectionProvider |
connectionProvider()
Get this configuration's underlying connection provider.
|
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(ConnectionProvider newConnectionProvider)
Create a derived configuration from this one, with a new connection
provider.
|
Configuration |
derive(ExecuteListenerProvider... newExecuteListenerProviders)
Create a derived configuration from this one, with new execute listener
providers.
|
Configuration |
derive(RecordListenerProvider... newRecordListenerProviders)
Create a derived configuration from this one, with new record listener
providers.
|
Configuration |
derive(RecordMapperProvider newRecordMapperProvider)
Create a derived configuration from this one, with a new record mapper
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(TransactionProvider newTransactionProvider)
Create a derived configuration from this one, with a new transaction
provider.
|
Configuration |
derive(VisitListenerProvider... newVisitListenerProviders)
Create a derived configuration from this one, with new visit listener
providers.
|
SQLDialect |
dialect()
Retrieve the configured dialect.
|
ExecuteListenerProvider[] |
executeListenerProviders()
Get the configured
ExecuteListenerProvider s from this
configuration. |
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.
|
SchemaMapping |
schemaMapping()
Deprecated.
- 2.0.5 - Use
settings() instead |
Configuration |
set(ConnectionProvider newConnectionProvider)
Change this configuration to hold a new connection provider.
|
Configuration |
set(ExecuteListenerProvider... newExecuteListenerProviders)
Change this configuration to hold a new execute listener providers.
|
Configuration |
set(RecordListenerProvider... newRecordListenerProviders)
Change this configuration to hold a new record listener providers.
|
Configuration |
set(RecordMapperProvider newRecordMapperProvider)
Change this configuration to hold a new record mapper 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(TransactionProvider newTransactionProvider)
Change this configuration to hold a new transaction provider.
|
Configuration |
set(VisitListenerProvider... newVisitListenerProviders)
Change this configuration to hold a new visit listener providers.
|
Settings |
settings()
Retrieve the runtime configuration settings.
|
TransactionProvider |
transactionProvider()
Get this configuration's underlying transaction provider.
|
VisitListenerProvider[] |
visitListenerProviders()
TODO [#2667]
|
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
ConnectionProvider connectionProvider()
TransactionProvider transactionProvider()
If no explicit transaction provider was specified, and if
connectionProvider()
is a DefaultConnectionProvider
,
then this will return a DefaultTransactionProvider
.
RecordMapperProvider recordMapperProvider()
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 SchemaMapping schemaMapping()
settings()
insteadSQLDialect dialect()
SQLDialect family()
Settings settings()
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(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(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(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(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(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(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(ConnectionProvider newConnectionProvider)
newConnectionProvider
- The new connection 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(RecordMapperProvider newRecordMapperProvider)
newRecordMapperProvider
- The new record mapper provider 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(ExecuteListenerProvider... newExecuteListenerProviders)
newExecuteListenerProviders
- The new execute listener providers 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(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 © 2014. All Rights Reserved.