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 SummaryConstructorsConstructorDescriptionConnectionHolder(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 SummaryModifier and TypeMethodDescriptionvoidclear()Clear the transactional state of this resource holder.Return the currentConnectionheld by thisConnectionHolder.protected booleanReturn whether this holder currently has aConnection.protected booleanReturn whether this holder represents an active, R2DBC-managed transaction.voidreleased()Releases the currentConnection.protected voidsetConnection(Connection connection) Override the existing Connection with the givenConnection.protected voidsetTransactionActive(boolean transactionActive) Set whether this holder represents an active, R2DBC-managed transaction.Methods inherited from class org.springframework.transaction.support.ResourceHolderSupportgetDeadline, getTimeToLiveInMillis, getTimeToLiveInSeconds, hasTimeout, isOpen, isRollbackOnly, isSynchronizedWithTransaction, isVoid, requested, reset, resetRollbackOnly, setRollbackOnly, setSynchronizedWithTransaction, setTimeoutInMillis, setTimeoutInSeconds, unbound
- 
Constructor Details- 
ConnectionHolderCreate a new ConnectionHolder for the given R2DBCConnection, assuming that there is no ongoing transaction.- Parameters:
- connection- the R2DBC- Connectionto hold
- See Also:
 
- 
ConnectionHolderCreate a new ConnectionHolder for the given R2DBCConnection.- Parameters:
- connection- the R2DBC- Connectionto hold
- transactionActive- whether the given- Connectionis involved in an ongoing transaction
 
 
- 
- 
Method Details- 
hasConnectionprotected boolean hasConnection()Return whether this holder currently has aConnection.
- 
setTransactionActiveprotected void setTransactionActive(boolean transactionActive) Set whether this holder represents an active, R2DBC-managed transaction.- See Also:
 
- 
isTransactionActiveprotected boolean isTransactionActive()Return whether this holder represents an active, R2DBC-managed transaction.
- 
setConnectionOverride the existing Connection with the givenConnection.Used for releasing the Connectionon suspend (with anullargument) and setting a freshConnectionon resume.
- 
getConnectionReturn the currentConnectionheld by thisConnectionHolder.This will be the same Connectionuntilreleasedgets called on theConnectionHolder, which will reset the heldConnection, fetching a newConnectionon demand.- See Also:
 
- 
releasedpublic void released()Releases the currentConnection.- Overrides:
- releasedin class- ResourceHolderSupport
 
- 
clearpublic void clear()Description copied from class:ResourceHolderSupportClear the transactional state of this resource holder.- Overrides:
- clearin class- ResourceHolderSupport
 
 
-