Class ExternalSqlClientPool
- java.lang.Object
-
- org.hibernate.reactive.pool.impl.SqlClientPool
-
- org.hibernate.reactive.pool.impl.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.xPool
.This is an alternative to
DefaultSqlClientPool
, for use when one doesn't want Hibernate Reactive to manage the lifecycle of the underlyingPool
.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 injectedPool
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 thePool
instance with aThreadLocal
could be devised by having all of the use of the Hibernate Reactive's SessionFactory instance (Stage.SessionFactory
or aMutiny.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, org.hibernate.engine.jdbc.spi.SqlExceptionHelper sqlExceptionHelper)
-
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()
org.hibernate.engine.jdbc.spi.SqlExceptionHelper
getSqlExceptionHelper()
protected org.hibernate.engine.jdbc.spi.SqlStatementLogger
getSqlStatementLogger()
-
Methods inherited from class org.hibernate.reactive.pool.impl.SqlClientPool
getConnection, getConnection, getConnection, getConnection, getTenantPool
-
-
-
-
Method Detail
-
getPool
protected io.vertx.sqlclient.Pool getPool()
- Specified by:
getPool
in classSqlClientPool
- Returns:
- the underlying Vert.x
Pool
for the current context.
-
getSqlStatementLogger
protected org.hibernate.engine.jdbc.spi.SqlStatementLogger getSqlStatementLogger()
- Specified by:
getSqlStatementLogger
in classSqlClientPool
- 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 classSqlClientPool
- Returns:
- a Hibernate
SqlExceptionHelper
for converting exceptions
-
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.
-
-