Record Class R2dbcConnectionState
java.lang.Object
java.lang.Record
io.micronaut.data.r2dbc.connection.R2dbcConnectionState
- Record Components:
autoCommit- The auto-commitisolationLevel- The isolation level
@Internal
public record R2dbcConnectionState(boolean autoCommit, @Nullable io.r2dbc.spi.IsolationLevel isolationLevel)
extends Record
The state of a connection when it was opened, restored before the connection is closed (returned to the pool).
Some drivers (e.g. Oracle R2DBC) keep auto-commit disabled after the transaction ends: a pooled connection
would run the next statements in an implicit transaction that is never committed.
The isolation level set by a transaction would also leak to the next user of the connection.
The initial state is the state of the connection handed out by the connection factory (pool). If it was already changed outside of Micronaut Data (e.g. by a raw connection usage), the changed state is preserved.
- Since:
- 5.3.0
- Author:
- Denis Stepanov
-
Constructor Summary
ConstructorsConstructorDescriptionR2dbcConnectionState(boolean autoCommit, @Nullable io.r2dbc.spi.IsolationLevel isolationLevel) Creates an instance of aR2dbcConnectionStaterecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the value of theautoCommitrecord component.static R2dbcConnectionStatecapture(io.r2dbc.spi.Connection connection) Capture the current state of the connection.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.@Nullable io.r2dbc.spi.IsolationLevelReturns the value of theisolationLevelrecord component.reactor.core.publisher.Mono<Void> restore(io.r2dbc.spi.Connection connection, org.slf4j.Logger log) Restore the state of the connection.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
R2dbcConnectionState
public R2dbcConnectionState(boolean autoCommit, @Nullable io.r2dbc.spi.IsolationLevel isolationLevel) Creates an instance of aR2dbcConnectionStaterecord class.- Parameters:
autoCommit- the value for theautoCommitrecord componentisolationLevel- the value for theisolationLevelrecord component
-
-
Method Details
-
capture
Capture the current state of the connection.- Parameters:
connection- The connection- Returns:
- The state
-
restore
public reactor.core.publisher.Mono<Void> restore(io.r2dbc.spi.Connection connection, org.slf4j.Logger log) Restore the state of the connection. An error is logged and not propagated, so the connection can be closed.- Parameters:
connection- The connectionlog- The logger- Returns:
- The publisher
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
autoCommit
public boolean autoCommit()Returns the value of theautoCommitrecord component.- Returns:
- the value of the
autoCommitrecord component
-
isolationLevel
public @Nullable io.r2dbc.spi.IsolationLevel isolationLevel()Returns the value of theisolationLevelrecord component.- Returns:
- the value of the
isolationLevelrecord component
-