Class ConnectionHolder
java.lang.Object
org.springframework.transaction.support.ResourceHolderSupport
org.springframework.r2dbc.connection.ConnectionHolder
- All Implemented Interfaces:
ResourceHolder
Resource holder wrapping a R2DBC
Connection
.
R2dbcTransactionManager
binds instances of this class to the subscription,
for a specific ConnectionFactory
.
Inherits rollback-only support for nested R2DBC transactions and reference count functionality from the base class.
Note: This is an SPI class, not intended to be used by applications.
- Since:
- 5.3
- Author:
- Mark Paluch, Christoph Strobl
- See Also:
-
Constructor Summary
ConstructorDescriptionConnectionHolder
(Connection connection) Create a new ConnectionHolder for the given R2DBCConnection
, assuming that there is no ongoing transaction.ConnectionHolder
(Connection connection, boolean transactionActive) Create a new ConnectionHolder for the given R2DBCConnection
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clear the transactional state of this resource holder.Return the currentConnection
held by thisConnectionHolder
.protected boolean
Return whether this holder currently has aConnection
.protected boolean
Return whether this holder represents an active, R2DBC-managed transaction.void
released()
Releases the currentConnection
.protected void
setConnection
(Connection connection) Override the existing Connection with the givenConnection
.protected void
setTransactionActive
(boolean transactionActive) Set whether this holder represents an active, R2DBC-managed transaction.Methods inherited from class org.springframework.transaction.support.ResourceHolderSupport
getDeadline, getTimeToLiveInMillis, getTimeToLiveInSeconds, hasTimeout, isOpen, isRollbackOnly, isSynchronizedWithTransaction, isVoid, requested, reset, resetRollbackOnly, setRollbackOnly, setSynchronizedWithTransaction, setTimeoutInMillis, setTimeoutInSeconds, unbound
-
Constructor Details
-
ConnectionHolder
Create a new ConnectionHolder for the given R2DBCConnection
, assuming that there is no ongoing transaction.- Parameters:
connection
- the R2DBCConnection
to hold- See Also:
-
ConnectionHolder
Create a new ConnectionHolder for the given R2DBCConnection
.- Parameters:
connection
- the R2DBCConnection
to holdtransactionActive
- whether the givenConnection
is involved in an ongoing transaction
-
-
Method Details
-
hasConnection
protected boolean hasConnection()Return whether this holder currently has aConnection
. -
setTransactionActive
protected void setTransactionActive(boolean transactionActive) Set whether this holder represents an active, R2DBC-managed transaction.- See Also:
-
isTransactionActive
protected boolean isTransactionActive()Return whether this holder represents an active, R2DBC-managed transaction. -
setConnection
Override the existing Connection with the givenConnection
.Used for releasing the
Connection
on suspend (with anull
argument) and setting a freshConnection
on resume. -
getConnection
Return the currentConnection
held by thisConnectionHolder
.This will be the same
Connection
untilreleased
gets called on theConnectionHolder
, which will reset the heldConnection
, fetching a newConnection
on demand.- See Also:
-
released
public void released()Releases the currentConnection
.- Overrides:
released
in classResourceHolderSupport
-
clear
public void clear()Description copied from class:ResourceHolderSupport
Clear the transactional state of this resource holder.- Overrides:
clear
in classResourceHolderSupport
-