Class SqlClientPool

java.lang.Object
org.hibernate.reactive.pool.impl.SqlClientPool
All Implemented Interfaces:
Serializable, ReactiveConnectionPool, org.hibernate.service.Service
Direct Known Subclasses:
DefaultSqlClientPool, ExternalSqlClientPool

public abstract class SqlClientPool extends Object implements ReactiveConnectionPool
A pool of reactive connections backed by a supplier of Vert.x Pool instances.

The Vert.x notion of pool is not to be confused with the traditional JDBC notion of a connection pool: there is a fundamental difference as the Vert.x pool should not be shared across threads or with other Vert.x contexts.

Therefore, the reactive SessionFactory doesn't retain a single instance of Pool, but rather has a supplier which produces a new Pool within each context.

See Also:
  • Constructor Details

    • SqlClientPool

      public SqlClientPool()
  • Method Details

    • getPool

      protected abstract io.vertx.sqlclient.Pool getPool()
      Returns:
      the underlying Vert.x Pool for the current context.
    • getSqlStatementLogger

      protected abstract org.hibernate.engine.jdbc.spi.SqlStatementLogger getSqlStatementLogger()
      Returns:
      a Hibernate SqlStatementLogger for logging SQL statements as they are executed
    • getSqlExceptionHelper

      protected abstract org.hibernate.engine.jdbc.spi.SqlExceptionHelper getSqlExceptionHelper()
      Returns:
      a Hibernate SqlExceptionHelper for converting exceptions
    • getTenantPool

      protected io.vertx.sqlclient.Pool getTenantPool(String tenantId)
      Get a Pool for the specified tenant.

      This is an unimplemented operation which must be overridden by subclasses which support multitenancy.

      Parameters:
      tenantId - the id of the tenant
      Throws:
      UnsupportedOperationException - if multitenancy is not supported
      See Also:
    • getConnection

      public CompletionStage<ReactiveConnection> getConnection()
      Description copied from interface: ReactiveConnectionPool
      Obtain a reactive connection, returning the connection via a CompletionStage.
      Specified by:
      getConnection in interface ReactiveConnectionPool
    • getConnection

      public CompletionStage<ReactiveConnection> getConnection(org.hibernate.engine.jdbc.spi.SqlExceptionHelper sqlExceptionHelper)
      Description copied from interface: ReactiveConnectionPool
      Obtain a reactive connection, returning the connection via a CompletionStage and overriding the default SqlExceptionHelper for the pool.
      Specified by:
      getConnection in interface ReactiveConnectionPool
    • getConnection

      public CompletionStage<ReactiveConnection> getConnection(String tenantId)
      Description copied from interface: ReactiveConnectionPool
      Obtain a reactive connection for the given tenant id, returning the connection via a CompletionStage.
      Specified by:
      getConnection in interface ReactiveConnectionPool
    • getConnection

      public CompletionStage<ReactiveConnection> getConnection(String tenantId, org.hibernate.engine.jdbc.spi.SqlExceptionHelper sqlExceptionHelper)
      Description copied from interface: ReactiveConnectionPool
      Obtain a reactive connection for the given tenant id, returning the connection via a CompletionStage and overriding the default SqlExceptionHelper for the pool.
      Specified by:
      getConnection in interface ReactiveConnectionPool
    • selectJdbcOutsideTransaction

      public CompletionStage<ResultSet> selectJdbcOutsideTransaction(String sql, Object[] paramValues)
      This method is intended to be used only for queries returning a ResultSet that must be executed outside any "current" transaction (i.e. with autocommit=true).

      For example, it would be appropriate to use this method when performing queries on information_schema or system tables in order to obtain metadata information about catalogs, schemas, tables, etc.

      Specified by:
      selectJdbcOutsideTransaction in interface ReactiveConnectionPool
      Parameters:
      sql - - the query to execute outside a transaction
      paramValues - - a non-null array of parameter values
      Returns:
      the CompletionStage from executing the query.