public class ConnectionHolder extends ResourceHolderSupport
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.
R2dbcTransactionManager
,
ConnectionFactoryUtils
Constructor and Description |
---|
ConnectionHolder(io.r2dbc.spi.Connection connection)
Create a new ConnectionHolder for the given R2DBC
Connection ,
assuming that there is no ongoing transaction. |
ConnectionHolder(io.r2dbc.spi.Connection connection,
boolean transactionActive)
Create a new ConnectionHolder for the given R2DBC
Connection . |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear the transactional state of this resource holder.
|
io.r2dbc.spi.Connection |
getConnection()
Return the current
Connection held by this ConnectionHolder . |
protected boolean |
hasConnection()
Return whether this holder currently has a
Connection . |
protected boolean |
isTransactionActive()
Return whether this holder represents an active, R2DBC-managed transaction.
|
void |
released()
Releases the current
Connection . |
protected void |
setConnection(io.r2dbc.spi.Connection connection)
Override the existing Connection with the given
Connection . |
protected void |
setTransactionActive(boolean transactionActive)
Set whether this holder represents an active, R2DBC-managed transaction.
|
getDeadline, getTimeToLiveInMillis, getTimeToLiveInSeconds, hasTimeout, isOpen, isRollbackOnly, isSynchronizedWithTransaction, isVoid, requested, reset, resetRollbackOnly, setRollbackOnly, setSynchronizedWithTransaction, setTimeoutInMillis, setTimeoutInSeconds, unbound
public ConnectionHolder(io.r2dbc.spi.Connection connection)
Connection
,
assuming that there is no ongoing transaction.connection
- the R2DBC Connection
to holdConnectionHolder(Connection, boolean)
public ConnectionHolder(io.r2dbc.spi.Connection connection, boolean transactionActive)
Connection
.connection
- the R2DBC Connection
to holdtransactionActive
- whether the given Connection
is involved
in an ongoing transactionprotected boolean hasConnection()
Connection
.protected void setTransactionActive(boolean transactionActive)
R2dbcTransactionManager
protected boolean isTransactionActive()
protected void setConnection(@Nullable io.r2dbc.spi.Connection connection)
Connection
.
Used for releasing the Connection
on suspend
(with a null
argument) and setting a fresh Connection
on resume.
public io.r2dbc.spi.Connection getConnection()
Connection
held by this ConnectionHolder
.
This will be the same Connection
until released
gets called
on the ConnectionHolder
, which will reset the held Connection
,
fetching a new Connection
on demand.
released()
public void released()
Connection
.released
in class ResourceHolderSupport
public void clear()
ResourceHolderSupport
clear
in class ResourceHolderSupport