Class ExternalSqlClientPool

  • All Implemented Interfaces:
    java.io.Serializable, ReactiveConnectionPool, org.hibernate.service.Service

    public final class ExternalSqlClientPool
    extends SqlClientPool
    A pool of reactive connections backed by a Vert.x Pool.

    This is an alternative to DefaultSqlClientPool, for use when one doesn't want Hibernate Reactive to manage the lifecycle of the underlying Pool.

    This implementation is meant to be used in Quarkus or other runtimes.

    N.B. the injected pool instance is required to be threadsafe, while the default implementation in Vert.x version 3 is not. So use this only by extensions of the default implementation which can deliver a different actual underlying Pool instance for each thread. All clients of the pool instances retrieved from the injected Pool instance are expected to be running on a Vert.x event loop. Integration tests in Hibernate Reactive run exclusively on the Vert.x event loop, however in practice this will need to be guaranteed by the integrating runtime as well. Alternatively, a valid integration mode which doesn't require wrapping the Pool instance with a ThreadLocal could be devised by having all of the use of the Hibernate Reactive's SessionFactory instance (Stage.SessionFactory or a Mutiny.SessionFactory) constrained within a single thread, running within the Vert.x event loop.

    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      ExternalSqlClientPool​(io.vertx.sqlclient.Pool pool, org.hibernate.engine.jdbc.spi.SqlStatementLogger sqlStatementLogger)  
      ExternalSqlClientPool​(io.vertx.sqlclient.Pool pool, org.hibernate.engine.jdbc.spi.SqlStatementLogger sqlStatementLogger, boolean usePostgresStyleParameters)
      Deprecated.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.concurrent.CompletionStage<java.lang.Void> getCloseFuture()
      Since this Service implementation does not implement @Stoppable and we're only adapting an externally provided pool, we will not actually close such provided pool when Hibernate ORM is shutdown (it doesn't own the lifecycle of this external component).
      protected io.vertx.sqlclient.Pool getPool()  
      protected org.hibernate.engine.jdbc.spi.SqlStatementLogger getSqlStatementLogger()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ExternalSqlClientPool

        public ExternalSqlClientPool​(io.vertx.sqlclient.Pool pool,
                                     org.hibernate.engine.jdbc.spi.SqlStatementLogger sqlStatementLogger)
      • ExternalSqlClientPool

        @Deprecated
        public ExternalSqlClientPool​(io.vertx.sqlclient.Pool pool,
                                     org.hibernate.engine.jdbc.spi.SqlStatementLogger sqlStatementLogger,
                                     boolean usePostgresStyleParameters)
        Deprecated.
    • Method Detail

      • 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
      • getCloseFuture

        public java.util.concurrent.CompletionStage<java.lang.Void> getCloseFuture()
        Since this Service implementation does not implement @Stoppable and we're only adapting an externally provided pool, we will not actually close such provided pool when Hibernate ORM is shutdown (it doesn't own the lifecycle of this external component). Therefore there is no need to wait for its shutdown and this method returns an already successfully completed CompletionStage.
        Returns: