use of org.hibernate.reactive.pool.impl.Parameters in project hibernate-reactive by hibernate.
the class ReactiveImprovedExtractionContextImpl method getQueryResultSet.
private ResultSet getQueryResultSet(String queryString, Object[] positionalParameters, CompletionStage<ReactiveConnection> connectionStage) {
final Object[] parametersToUse = positionalParameters != null ? positionalParameters : new Object[0];
final Parameters parametersDialectSpecific = Parameters.instance(getJdbcEnvironment().getDialect());
final String queryToUse = parametersDialectSpecific.process(queryString, parametersToUse.length);
return connectionStage.thenCompose(c -> c.selectJdbcOutsideTransaction(queryToUse, parametersToUse)).whenComplete((resultSet, err) -> logSqlException(err, () -> "could not execute query ", queryToUse)).thenApply(ResultSetWorkaround::new).toCompletableFuture().join();
}
use of org.hibernate.reactive.pool.impl.Parameters in project hibernate-reactive by hibernate.
the class TableReactiveIdentifierGenerator method configure.
@Override
public void configure(Type type, Properties params, ServiceRegistry serviceRegistry) {
JdbcEnvironment jdbcEnvironment = serviceRegistry.getService(JdbcEnvironment.class);
Dialect dialect = jdbcEnvironment.getDialect();
QualifiedName qualifiedTableName = determineTableName(params, serviceRegistry);
segmentColumnName = determineSegmentColumnName(params, jdbcEnvironment);
valueColumnName = determineValueColumnNameForTable(params, jdbcEnvironment);
segmentValue = determineSegmentValue(params);
initialValue = determineInitialValue(params);
increment = determineIncrement(params);
storeLastUsedValue = determineStoreLastUsedValue(serviceRegistry);
// allow physical naming strategies a chance to kick in
renderedTableName = jdbcEnvironment.getQualifiedObjectNameFormatter().format(qualifiedTableName, dialect);
Parameters parameters = Parameters.instance(dialect);
selectQuery = parameters.process(applyLocksToSelect(dialect, "tbl", buildSelectQuery()));
updateQuery = parameters.process(buildUpdateQuery());
insertQuery = parameters.process(buildInsertQuery());
}
use of org.hibernate.reactive.pool.impl.Parameters in project hibernate-reactive by hibernate.
the class ReactivePlanEntityLoader method load.
@Override
public CompletionStage<Object> load(Serializable id, Object optionalObject, SharedSessionContractImplementor session, LockOptions lockOptions, Boolean readOnly) {
final QueryParameters parameters = buildQueryParameters(id, optionalObject, lockOptions, readOnly);
// Filters get applied just before the query is executed. The parameter processor is not smart enough
// to count deal with the additional parameters in a second pass and we have to wait until the query
// is complete before processing it. See: ReactiveLoader#executeReactiveQueryStatement
String sql = hasFilters(session) ? getStaticLoadQuery().getSqlStatement() : processedSQL;
return doReactiveQueryAndInitializeNonLazyCollections(sql, session, parameters).thenApply(results -> extractEntityResult(results, id)).handle((list, err) -> {
logSqlException(err, () -> "could not load an entity: " + infoString(persister, id, persister.getIdentifierType(), getFactory()), sql);
return returnOrRethrow(err, list);
});
}
Aggregations