Top Description Inners Fields Constructors Methods
org.jooq.impl

public Class DefaultTransactionProvider

extends Object
implements TransactionProvider
Class Inheritance
All Implemented Interfaces
org.jooq.TransactionProvider
Static Imports
java.lang.Boolean.TRUE, org.jooq.impl.Tools.BooleanDataKey.DATA_DEFAULT_TRANSACTION_PROVIDER_AUTOCOMMIT, .Tools.SimpleDataKey.DATA_DEFAULT_TRANSACTION_PROVIDER_CONNECTION, .Tools.SimpleDataKey.DATA_DEFAULT_TRANSACTION_PROVIDER_SAVEPOINTS

A default implementation for the TransactionProvider SPI.

This implementation is entirely based on JDBC transactions and is intended to work with DefaultConnectionProvider (which is implicitly created when using DSL#using(Connection)).

Nesting of transactions

By default, nested transactions are supported by modeling them implicitly with JDBC Savepoints, if supported by the underlying JDBC driver, and if nested() is true. To deactivate nested transactions, use DefaultTransactionProvider(ConnectionProvider, boolean).
Author
Lukas Eder

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final ConnectionProvider
private static final Savepoint
IGNORED_SAVEPOINT

This Savepoint serves as a marker for top level transactions if nested() transactions are deactivated.

private final boolean

Constructor Summary

AccessConstructor and Description
public
public
DefaultTransactionProvider(ConnectionProvider connectionProvider, boolean
Whether nested transactions via Savepoints are supported.
nested
)

Method Summary

Modifier and TypeMethod and Description
private final boolean
autoCommit(Configuration configuration)

public final void
begin(TransactionContext
the configuration scoped to this transaction and its nested transactions.
ctx
)

Implements org.jooq.TransactionProvider.begin.

Begin a new transaction.
private final void
brace(Configuration configuration, boolean start)

Ensure an autoCommit value on the connection, if it was set to true, originally.

public final void
commit(TransactionContext
the configuration scoped to this transaction and its nested transactions.
ctx
)

Implements org.jooq.TransactionProvider.commit.

Commit a transaction.
private final DefaultConnectionProvider
connection(Configuration configuration)

public final boolean
pack-priv final int
nestingLevel(Configuration configuration)

public final void
rollback(TransactionContext
the configuration scoped to this transaction and its nested transactions.
ctx
)

Implements org.jooq.TransactionProvider.rollback.

Rollback a transaction.
private final Deque<Savepoint>
savepoints(Configuration configuration)

private final Savepoint
setSavepoint(Configuration configuration, boolean topLevel)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

connectionProviderback to summary
private final ConnectionProvider connectionProvider
IGNORED_SAVEPOINTback to summary
private static final Savepoint IGNORED_SAVEPOINT

This Savepoint serves as a marker for top level transactions if nested() transactions are deactivated.

nestedback to summary
private final boolean nested

Constructor Detail

DefaultTransactionProviderback to summary
public DefaultTransactionProvider(ConnectionProvider connectionProvider)
DefaultTransactionProviderback to summary
public DefaultTransactionProvider(ConnectionProvider connectionProvider, boolean nested)
Parameters
nested:boolean

Whether nested transactions via Savepoints are supported.

Method Detail

autoCommitback to summary
private final boolean autoCommit(Configuration configuration)
beginback to summary
public final void begin(TransactionContext ctx)

Implements org.jooq.TransactionProvider.begin.

Doc from org.jooq.TransactionProvider.begin.

Begin a new transaction.

This method begins a new transaction with a Configuration scoped for this transaction. The resulting Transaction object may be used by implementors to identify the transaction when commit(TransactionContext) or rollback(TransactionContext) is called.

Parameters
ctx:TransactionContext

the configuration scoped to this transaction and its nested transactions.

Annotations
@Override
braceback to summary
private final void brace(Configuration configuration, boolean start)

Ensure an autoCommit value on the connection, if it was set to true, originally.

commitback to summary
public final void commit(TransactionContext ctx)

Implements org.jooq.TransactionProvider.commit.

Doc from org.jooq.TransactionProvider.commit.

Commit a transaction.

Parameters
ctx:TransactionContext

the configuration scoped to this transaction and its nested transactions.

Annotations
@Override
connectionback to summary
private final DefaultConnectionProvider connection(Configuration configuration)
nestedback to summary
public final boolean nested()
nestingLevelback to summary
pack-priv final int nestingLevel(Configuration configuration)
rollbackback to summary
public final void rollback(TransactionContext ctx)

Implements org.jooq.TransactionProvider.rollback.

Doc from org.jooq.TransactionProvider.rollback.

Rollback a transaction.

Parameters
ctx:TransactionContext

the configuration scoped to this transaction and its nested transactions.

Annotations
@Override
savepointsback to summary
private final Deque<Savepoint> savepoints(Configuration configuration)
Annotations
@SuppressWarnings:unchecked
setSavepointback to summary
private final Savepoint setSavepoint(Configuration configuration, boolean topLevel)
org.jooq.impl back to summary

private Class DefaultTransactionProvider.DefaultSavepoint

extends Object
implements Savepoint
Class Inheritance
All Implemented Interfaces
java.sql.Savepoint

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public int
getSavepointId()

Implements java.sql.Savepoint.getSavepointId.

Retrieves the generated ID for the savepoint that this Savepoint object represents.
public String
getSavepointName()

Implements java.sql.Savepoint.getSavepointName.

Retrieves the name of the savepoint that this Savepoint object represents.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

DefaultSavepointback to summary
private DefaultSavepoint()

Method Detail

getSavepointIdback to summary
public int getSavepointId() throws SQLException

Implements java.sql.Savepoint.getSavepointId.

Doc from java.sql.Savepoint.getSavepointId.

Retrieves the generated ID for the savepoint that this Savepoint object represents.

Returns:int

the numeric ID of this savepoint

Annotations
@Override
Exceptions
SQLException:
if this is a named savepoint
getSavepointNameback to summary
public String getSavepointName() throws SQLException

Implements java.sql.Savepoint.getSavepointName.

Doc from java.sql.Savepoint.getSavepointName.

Retrieves the name of the savepoint that this Savepoint object represents.

Returns:String

the name of this savepoint

Annotations
@Override
Exceptions
SQLException:
if this is an un-named savepoint