use of org.hibernate.reactive.loader.ReactiveLoader 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