org.jooq
Interface Configuration

All Superinterfaces:
Serializable
All Known Subinterfaces:
BindContext, Context<C>, ExecuteContext, FactoryOperations, RenderContext
All Known Implementing Classes:
ASEFactory, CUBRIDFactory, DB2Factory, DerbyFactory, Factory, FactoryProxy, FirebirdFactory, H2Factory, HSQLDBFactory, IngresFactory, MySQLFactory, OracleFactory, PostgresFactory, SQLiteFactory, SQLServerFactory, SybaseFactory

public interface Configuration
extends Serializable

The Configuration holds data about sql dialects, connections / data sources, and custom settings as well as custom data.

Essentially, the lifecycle of all objects in Configuration is the same. It corresponds to the lifecycle of a single Query and its rendering, variable binding, execution, and data fetching phases. This is also reflected in the fact that ExecuteListener objects are re-created every time a Query is executed

However, Configuration / Factory may be reused for several consecutive queries in a single thread, if the supplied Connection / DataSource allows this and if client code can live with the possibility of stale state in getData() between executions

Author:
Lukas Eder

Method Summary
 Connection getConnection()
          Retrieve the configured connection If you configured a data source for this Configuration (see setDataSource(DataSource)), then this may initialise a new connection.
 Map<String,Object> getData()
          Get all custom data from this Configuration This is custom data that was previously set to the configuration using setData(String, Object).
 Object getData(String key)
          Get some custom data from this Configuration This is custom data that was previously set to the configuration using setData(String, Object).
 DataSource getDataSource()
          Retrieve the configured data source
 SQLDialect getDialect()
          Retrieve the configured dialect
 SchemaMapping getSchemaMapping()
          Deprecated. - 2.0.5 - Use getSettings() instead
 Settings getSettings()
          Retrieve the runtime configuration settings
 void setConnection(Connection connection)
          Set the configured connection If you provide a JDBC connection to a jOOQ Factory, jOOQ will use that connection for creating statements, but it will never call any of these methods: Connection.commit() Connection.rollback() Connection.close() Use this constructor if you want to handle transactions directly on the connection.
 Object setData(String key, Object value)
          Set some custom data to this 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.
 void setDataSource(DataSource datasource)
          Set the configured data source If you provide a JDBC data source to a jOOQ Factory, jOOQ will use that data source for initialising connections, and creating statements.
 

Method Detail

getDialect

SQLDialect getDialect()
Retrieve the configured dialect


getDataSource

DataSource getDataSource()
Retrieve the configured data source


setDataSource

void setDataSource(DataSource datasource)
Set the configured data source

If you provide a JDBC data source to a jOOQ Factory, jOOQ will use that data source for initialising connections, and creating statements.

Use data sources if you want to run distributed transactions, such as javax.transaction.UserTransaction. If you provide jOOQ factories with a data source, jOOQ will close() all connections after query execution in order to return the connection to the connection pool. If you do not use distributed transactions, this will produce driver-specific behaviour at the end of query execution at close() invocation (e.g. a transaction rollback). Use setConnection(Connection) instead, to control the connection's lifecycle.


getConnection

Connection getConnection()
Retrieve the configured connection

If you configured a data source for this Configuration (see setDataSource(DataSource)), then this may initialise a new connection.


setConnection

void setConnection(Connection connection)
Set the configured connection

If you provide a JDBC connection to a jOOQ Factory, jOOQ will use that connection for creating statements, but it will never call any of these methods:

Use this constructor if you want to handle transactions directly on the connection.


getSchemaMapping

@Deprecated
SchemaMapping getSchemaMapping()
Deprecated. - 2.0.5 - Use getSettings() instead

Retrieve the configured schema mapping


getSettings

Settings getSettings()
Retrieve the runtime configuration settings


getData

Map<String,Object> getData()
Get all custom data from this Configuration

This is custom data that was previously set to the configuration using setData(String, 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.

Returns:
The custom data. This is never null
See Also:
ExecuteListener

getData

Object getData(String key)
Get some custom data from this Configuration

This is custom data that was previously set to the configuration using setData(String, 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.

Parameters:
key - A key to identify the custom data
Returns:
The custom data or null if no such data is contained in this Configuration
See Also:
ExecuteListener

setData

Object setData(String key,
               Object value)
Set some custom data to this 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.

Parameters:
key - A key to identify the custom data
value - The custom data or null to unset the custom data
Returns:
The previously set custom data or null if no data was previously set for the given key
See Also:
ExecuteListener


Copyright © 2012. All Rights Reserved.