Interface ConnectionHolder


public interface ConnectionHolder

The server facing side of a LocalEntityConnection: one whose underlying JDBC connection is attached and detached by its owner, the way the server runs a client's connection on one borrowed from a connection pool for the duration of an invocation, or replaces one which has gone bad, in place.

Connections created via LocalEntityConnection.localEntityConnection(is.codion.common.db.database.Database, is.codion.framework.domain.Domain, is.codion.common.utilities.user.User) implement this, reached by casting:

 ((ConnectionHolder) entityConnection).attach(connectionPool.connection(user));
A self-managing connection, see LocalEntityConnection.builder(), does not implement this, its underlying connection being its own to manage.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    attach(Connection connection)
    Attaches the given JDBC connection, which is used 'as is': no validation or transaction checking is performed and auto-commit is assumed to be disabled.
    Detaches and returns the underlying JDBC connection, leaving this connection without one - methods requiring it throw DatabaseException until one is attached.
  • Method Details

    • attach

      void attach(Connection connection)

      Attaches the given JDBC connection, which is used 'as is': no validation or transaction checking is performed and auto-commit is assumed to be disabled.

      Note that this does not reset the transaction state; the caller is responsible for ensuring no transaction is considered open when swapping the underlying connection.

      Parameters:
      connection - the connection to attach
    • detach

      Detaches and returns the underlying JDBC connection, leaving this connection without one - methods requiring it throw DatabaseException until one is attached.

      Returns:
      the detached connection, or null in case none was attached