Class ExternalSqlClientPool
- All Implemented Interfaces:
Serializable,ReactiveConnectionPool,org.hibernate.service.Service
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:
-
Constructor Summary
ConstructorsConstructorDescriptionExternalSqlClientPool(io.vertx.sqlclient.Pool pool, org.hibernate.engine.jdbc.spi.SqlStatementLogger sqlStatementLogger, org.hibernate.engine.jdbc.spi.SqlExceptionHelper sqlExceptionHelper) -
Method Summary
Modifier and TypeMethodDescriptionSince this Service implementation does not implement @Stoppableand 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.PoolgetPool()org.hibernate.engine.jdbc.spi.SqlExceptionHelperprotected org.hibernate.engine.jdbc.spi.SqlStatementLoggerCompletionStage<io.vertx.sqlclient.RowSet<io.vertx.sqlclient.Row>>preparedQueryOutsideTransaction(String sql, io.vertx.sqlclient.Tuple parameters) 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.Methods inherited from class org.hibernate.reactive.pool.impl.SqlClientPool
getConnection, getConnection, getConnection, getConnection, getTenantPool
-
Constructor Details
-
ExternalSqlClientPool
public ExternalSqlClientPool(io.vertx.sqlclient.Pool pool, org.hibernate.engine.jdbc.spi.SqlStatementLogger sqlStatementLogger, org.hibernate.engine.jdbc.spi.SqlExceptionHelper sqlExceptionHelper)
-
-
Method Details
-
getPool
protected io.vertx.sqlclient.Pool getPool()- Specified by:
getPoolin classSqlClientPool- Returns:
- the underlying Vert.x
Poolfor the current context.
-
getSqlStatementLogger
protected org.hibernate.engine.jdbc.spi.SqlStatementLogger getSqlStatementLogger()- Specified by:
getSqlStatementLoggerin classSqlClientPool- Returns:
- a Hibernate
SqlStatementLoggerfor logging SQL statements as they are executed
-
getSqlExceptionHelper
public org.hibernate.engine.jdbc.spi.SqlExceptionHelper getSqlExceptionHelper()- Specified by:
getSqlExceptionHelperin classSqlClientPool- Returns:
- a Hibernate
SqlExceptionHelperfor converting exceptions
-
getCloseFuture
Since this Service implementation does not implement @Stoppableand 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. -
selectJdbcOutsideTransaction
Description copied from class:SqlClientPoolThis 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:
selectJdbcOutsideTransactionin interfaceReactiveConnectionPool- Overrides:
selectJdbcOutsideTransactionin classSqlClientPool- Parameters:
sql- - the query to execute outside a transactionparamValues- - a non-null array of parameter values- Returns:
- the CompletionStage
from executing the query.
-
preparedQueryOutsideTransaction
public CompletionStage<io.vertx.sqlclient.RowSet<io.vertx.sqlclient.Row>> preparedQueryOutsideTransaction(String sql, io.vertx.sqlclient.Tuple parameters)
-