Top Description Inners Fields Constructors Methods
org.jooq.impl

public Class ThreadLocalTransactionProvider

extends Object
implements TransactionProvider
Class Inheritance
All Implemented Interfaces
org.jooq.TransactionProvider
Static Imports
org.jooq.impl.Tools.SimpleDataKey.DATA_DEFAULT_TRANSACTION_PROVIDER_CONNECTION

A TransactionProvider that implements thread-bound transaction semantics.

Use this TransactionProvider if your transactions are thread-bound, meaning that a transaction and its underlying Connection will never leave the thread that started the transaction.

When this TransactionProvider is used, users must pass their custom ConnectionProvider implementations to this TransactionProvider, instead of passing it to the Configuration.

Author
Lukas Eder

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class

Field Summary

Modifier and TypeField and Description
pack-priv final DefaultTransactionProvider
pack-priv final ThreadLocal<Deque<Configuration>>
pack-priv final ThreadLocalTransactionProvider.ThreadLocalConnectionProvider
pack-priv final ThreadLocal<Connection>

Constructor Summary

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

Method Summary

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

Implements org.jooq.TransactionProvider.begin.

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

Implements org.jooq.TransactionProvider.commit.

Commit a transaction.
pack-priv Configuration
private Deque<Configuration>
public void
rollback(TransactionContext
the configuration scoped to this transaction and its nested transactions.
ctx
)

Implements org.jooq.TransactionProvider.rollback.

Rollback a transaction.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegateTransactionProviderback to summary
pack-priv final DefaultTransactionProvider delegateTransactionProvider
localConfigurationsback to summary
pack-priv final ThreadLocal<Deque<Configuration>> localConfigurations
localConnectionProviderback to summary
pack-priv final ThreadLocalTransactionProvider.ThreadLocalConnectionProvider localConnectionProvider
localTxConnectionback to summary
pack-priv final ThreadLocal<Connection> localTxConnection

Constructor Detail

ThreadLocalTransactionProviderback to summary
public ThreadLocalTransactionProvider(ConnectionProvider connectionProvider)
ThreadLocalTransactionProviderback to summary
public ThreadLocalTransactionProvider(ConnectionProvider connectionProvider, boolean nested)
Parameters
nested:boolean

Whether nested transactions via Savepoints are supported.

Method Detail

beginback to summary
public 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
commitback to summary
public 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
configurationback to summary
pack-priv Configuration configuration(Configuration fallback)
configurationsback to summary
private Deque<Configuration> configurations()
rollbackback to summary
public 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
org.jooq.impl back to summary

pack-priv final Class ThreadLocalTransactionProvider.ThreadLocalConnectionProvider

extends Object
implements ConnectionProvider
Class Inheritance
  • java.lang.Object
  • org.jooq.impl.ThreadLocalTransactionProvider.ThreadLocalConnectionProvider
All Implemented Interfaces
org.jooq.ConnectionProvider

Field Summary

Modifier and TypeField and Description
pack-priv final ConnectionProvider

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final Connection
acquire()

Implements org.jooq.ConnectionProvider.acquire.

Acquire a connection from the connection lifecycle handler.
public final void
release(Connection
A connection that was previously obtained from acquire(). This is never null.
connection
)

Implements org.jooq.ConnectionProvider.release.

Release a connection to the connection lifecycle handler.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegateConnectionProviderback to summary
pack-priv final ConnectionProvider delegateConnectionProvider

Constructor Detail

ThreadLocalConnectionProviderback to summary
public ThreadLocalConnectionProvider(ConnectionProvider delegate)

Method Detail

acquireback to summary
public final Connection acquire()

Implements org.jooq.ConnectionProvider.acquire.

Doc from org.jooq.ConnectionProvider.acquire.

Acquire a connection from the connection lifecycle handler.

This method is called by jOOQ exactly once per execution lifecycle, i.e. per ExecuteContext. Implementations may freely chose, whether subsequent calls to this method:

  • return the same connection instance
  • return the same connection instance for the same thread
  • return the same connection instance for the same transaction (e.g. a javax.transaction.UserTransaction)
  • return a fresh connection instance every time

jOOQ will guarantee that every acquired connection is released through release(Connection) exactly once.

Returns:Connection

A connection for the current ExecuteContext. If null is returned (e.g. by NoConnectionProvider), then statements cannot be executed. Attempts to execute statements will result in a DetachedException.

Annotations
@Override
releaseback to summary
public final void release(Connection connection)

Implements org.jooq.ConnectionProvider.release.

Doc from org.jooq.ConnectionProvider.release.

Release a connection to the connection lifecycle handler.

jOOQ will guarantee that every acquired connection is released exactly once.

Parameters
connection:Connection

A connection that was previously obtained from acquire(). This is never null.

Annotations
@Override