Record Class R2dbcConnectionState

java.lang.Object
java.lang.Record
io.micronaut.data.r2dbc.connection.R2dbcConnectionState
Record Components:
autoCommit - The auto-commit
isolationLevel - 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

    Constructors
    Constructor
    Description
    R2dbcConnectionState(boolean autoCommit, @Nullable io.r2dbc.spi.IsolationLevel isolationLevel)
    Creates an instance of a R2dbcConnectionState record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns the value of the autoCommit record component.
    capture(io.r2dbc.spi.Connection connection)
    Capture the current state of the connection.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    @Nullable io.r2dbc.spi.IsolationLevel
    Returns the value of the isolationLevel record component.
    reactor.core.publisher.Mono<Void>
    restore(io.r2dbc.spi.Connection connection, org.slf4j.Logger log)
    Restore the state of the connection.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • R2dbcConnectionState

      public R2dbcConnectionState(boolean autoCommit, @Nullable io.r2dbc.spi.IsolationLevel isolationLevel)
      Creates an instance of a R2dbcConnectionState record class.
      Parameters:
      autoCommit - the value for the autoCommit record component
      isolationLevel - the value for the isolationLevel record component
  • Method Details

    • capture

      public static R2dbcConnectionState capture(io.r2dbc.spi.Connection connection)
      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 connection
      log - The logger
      Returns:
      The publisher
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • autoCommit

      public boolean autoCommit()
      Returns the value of the autoCommit record component.
      Returns:
      the value of the autoCommit record component
    • isolationLevel

      public @Nullable io.r2dbc.spi.IsolationLevel isolationLevel()
      Returns the value of the isolationLevel record component.
      Returns:
      the value of the isolationLevel record component