Class DefaultSqlClientPool

java.lang.Object
org.hibernate.reactive.pool.impl.SqlClientPool
org.hibernate.reactive.pool.impl.DefaultSqlClientPool
All Implemented Interfaces:
Serializable, ReactiveConnectionPool, org.hibernate.service.Service, org.hibernate.service.spi.Configurable, org.hibernate.service.spi.ServiceRegistryAwareService, org.hibernate.service.spi.Startable, org.hibernate.service.spi.Stoppable

public class DefaultSqlClientPool extends SqlClientPool implements org.hibernate.service.spi.ServiceRegistryAwareService, org.hibernate.service.spi.Configurable, org.hibernate.service.spi.Stoppable, org.hibernate.service.spi.Startable
A pool of reactive connections backed by a Vert.x Pool. The Pool itself is backed by an instance of Vertx obtained via the VertxInstance service. Configuration of the Pool is handled by the SqlClientPoolConfiguration service.

This class may be extended by programs which wish to implement custom connection management or multitenancy.

The lifecycle of this pool is managed by Hibernate Reactive: it is created when the reactive SessionFactory is created and destroyed when the SessionFactory is destroyed. For cases where the underlying Pool lifecycle is managed externally to Hibernate, use ExternalSqlClientPool.

See Also:
  • Constructor Details

    • DefaultSqlClientPool

      public DefaultSqlClientPool()
  • Method Details

    • injectServices

      public void injectServices(org.hibernate.service.spi.ServiceRegistryImplementor serviceRegistry)
      Specified by:
      injectServices in interface org.hibernate.service.spi.ServiceRegistryAwareService
    • configure

      public void configure(Map<String,Object> configuration)
      Specified by:
      configure in interface org.hibernate.service.spi.Configurable
    • start

      public void start()
      Specified by:
      start in interface org.hibernate.service.spi.Startable
    • getCloseFuture

      public CompletionStage<Void> getCloseFuture()
      Description copied from interface: ReactiveConnectionPool
      The shutdown of the pool is actually asynchronous but the core service registry won't return the CompletionStage. If you need to wait for the underlying pool to be closed, after closing the SessionFactory you can get the CompletionStage instance from this getter.
      Specified by:
      getCloseFuture in interface ReactiveConnectionPool
    • getPool

      protected io.vertx.sqlclient.Pool getPool()
      Specified by:
      getPool in class SqlClientPool
      Returns:
      the underlying Vert.x Pool for the current context.
    • getSqlStatementLogger

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

      public org.hibernate.engine.jdbc.spi.SqlExceptionHelper getSqlExceptionHelper()
      Specified by:
      getSqlExceptionHelper in class SqlClientPool
      Returns:
      a Hibernate SqlExceptionHelper for converting exceptions
    • createPool

      protected io.vertx.sqlclient.Pool createPool(URI uri)
      Create a new Pool for the given JDBC URL or database URI, using the VertxInstance service to obtain an instance of Vertx, and the SqlClientPoolConfiguration service to obtain options for creating the connection pool instances.
      Parameters:
      uri - JDBC URL or database URI
      Returns:
      the new Pool
    • createPool

      protected io.vertx.sqlclient.Pool createPool(URI uri, io.vertx.sqlclient.SqlConnectOptions connectOptions, io.vertx.sqlclient.PoolOptions poolOptions, io.vertx.core.Vertx vertx)
      Create a new Pool for the given JDBC URL or database URI, connection pool options, and the given instance of Vertx.
      Parameters:
      uri - JDBC URL or database URI
      connectOptions - the connection options
      poolOptions - the connection pooling options
      vertx - the instance of Vertx to be used by the pool
      Returns:
      the new Pool
    • jdbcUrl

      protected URI jdbcUrl(Map<?,?> configurationValues)
      Determine the JDBC URL or database URI from the given configuration.
      Parameters:
      configurationValues - the configuration properties
      Returns:
      the JDBC URL as a URI
    • stop

      public void stop()
      Specified by:
      stop in interface org.hibernate.service.spi.Stoppable
    • parse

      public static URI parse(String url)