Class R2dbcTransactionManager
- All Implemented Interfaces:
Serializable
,InitializingBean
,ReactiveTransactionManager
,TransactionManager
ReactiveTransactionManager
implementation for a single R2DBC
ConnectionFactory
. This class is capable of working in any environment with any R2DBC driver, as long as the
setup uses a ConnectionFactory
as its Connection
factory mechanism. Binds a R2DBC Connection
from the specified ConnectionFactory
to the current subscriber context, potentially allowing for one
context-bound Connection
per ConnectionFactory
.
Note: The ConnectionFactory
that this transaction manager operates on needs to return independent
Connection
s. The Connection
s may come from a pool (the typical case), but the
ConnectionFactory
must not return scoped scoped Connection
s or the like. This transaction manager
will associate Connection
with context-bound transactions itself, according to the specified propagation
behavior. It assumes that a separate, independent Connection
can be obtained even during an ongoing
transaction.
Application code is required to retrieve the R2DBC Connection via
ConnectionFactoryUtils.getConnection(ConnectionFactory)
instead of a standard R2DBC-style
ConnectionFactory.create()
call. Spring classes such as DatabaseClient
use this strategy implicitly.
If not used in combination with this transaction manager, the ConnectionFactoryUtils
lookup strategy behaves
exactly like the native ConnectionFactory
lookup; it can thus be used in a portable fashion.
Alternatively, you can allow application code to work with the standard R2DBC lookup pattern
ConnectionFactory.create()
, for example for code that is not aware of Spring at all. In that case, define a
TransactionAwareConnectionFactoryProxy
for your target ConnectionFactory
, and pass that proxy
ConnectionFactory
to your DAOs, which will automatically participate in Spring-managed transactions when
accessing it.
This transaction manager triggers flush callbacks on registered transaction synchronizations (if synchronization is
generally active), assuming resources operating on the underlying R2DBC Connection
.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.transaction.reactive.AbstractReactiveTransactionManager
AbstractReactiveTransactionManager.SuspendedResourcesHolder
-
Field Summary
Fields inherited from class org.springframework.transaction.reactive.AbstractReactiveTransactionManager
logger
-
Constructor Summary
ConstructorDescriptionDeprecated.Create a new @link ConnectionFactoryTransactionManager} instance.R2dbcTransactionManager
(ConnectionFactory connectionFactory) Deprecated.Create a newR2dbcTransactionManager
instance. -
Method Summary
Methods inherited from class org.springframework.r2dbc.connection.R2dbcTransactionManager
afterPropertiesSet, determineTimeout, doBegin, doCleanupAfterCompletion, doCommit, doGetTransaction, doResume, doRollback, doSetRollbackOnly, doSuspend, getConnectionFactory, isEnforceReadOnly, isExistingTransaction, obtainConnectionFactory, prepareTransactionalConnection, resolveIsolationLevel, setConnectionFactory, setEnforceReadOnly, translateException
Methods inherited from class org.springframework.transaction.reactive.AbstractReactiveTransactionManager
commit, getReactiveTransaction, prepareForCommit, registerAfterCompletionWithExistingTransaction, rollback
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.beans.factory.InitializingBean
afterPropertiesSet
-
Constructor Details
-
R2dbcTransactionManager
public R2dbcTransactionManager()Deprecated.Create a new @link ConnectionFactoryTransactionManager} instance. A ConnectionFactory has to be set to be able to use it. -
R2dbcTransactionManager
Deprecated.Create a newR2dbcTransactionManager
instance.- Parameters:
connectionFactory
- the R2DBC ConnectionFactory to manage transactions for
-
R2dbcTransactionManager
instead.