24
24
import org .hibernate .query .spi .QueryOptions ;
25
25
import org .hibernate .query .spi .QueryOptionsAdapter ;
26
26
import org .hibernate .reactive .loader .ast .spi .ReactiveSingleIdEntityLoader ;
27
+ import org .hibernate .reactive .sql .exec .internal .StandardReactiveSelectExecutor ;
28
+ import org .hibernate .reactive .sql .results .spi .ReactiveListResultsConsumer ;
27
29
import org .hibernate .sql .ast .SqlAstTranslatorFactory ;
28
30
import org .hibernate .sql .ast .tree .expression .JdbcParameter ;
29
31
import org .hibernate .sql .ast .tree .select .SelectStatement ;
34
36
import org .hibernate .sql .exec .spi .JdbcParameterBindings ;
35
37
import org .hibernate .sql .results .graph .entity .LoadingEntityEntry ;
36
38
import org .hibernate .sql .results .internal .RowTransformerStandardImpl ;
37
- import org .hibernate .sql .results .spi .ListResultsConsumer ;
38
39
39
40
import org .jboss .logging .Logger ;
40
41
41
- import static org .hibernate .reactive .util .impl .CompletionStages .completedFuture ;
42
42
43
43
/**
44
44
* @see org.hibernate.loader.ast.internal.SingleIdEntityLoaderDynamicBatch
@@ -167,7 +167,7 @@ public CompletionStage<T> load(
167
167
jdbcParameterBindings
168
168
);
169
169
170
- session . getJdbcServices (). getJdbcSelectExecutor () .list (
170
+ return StandardReactiveSelectExecutor . INSTANCE .list (
171
171
jdbcSelect ,
172
172
jdbcParameterBindings ,
173
173
getExecutionContext (
@@ -179,20 +179,21 @@ public CompletionStage<T> load(
179
179
subSelectFetchableKeysHandler
180
180
),
181
181
RowTransformerStandardImpl .instance (),
182
- ListResultsConsumer .UniqueSemantic .FILTER
183
- );
184
-
185
- //noinspection ForLoopReplaceableByForEach
186
- for ( int i = 0 ; i < idsToLoad .length ; i ++ ) {
187
- final Object id = idsToLoad [i ];
188
- // found or not, remove the key from the batch-fetch queye
189
- BatchFetchQueueHelper .removeBatchLoadableEntityKey ( id , getLoadable (), session );
190
- }
191
-
192
- final EntityKey entityKey = session .generateEntityKey ( pkValue , getLoadable ().getEntityPersister () );
193
- //noinspection unchecked
194
- return completedFuture ( (T ) session .getPersistenceContext ().getEntity ( entityKey ) );
195
-
182
+ ReactiveListResultsConsumer .UniqueSemantic .FILTER
183
+ )
184
+ .thenApply ( results -> {
185
+ //noinspection ForLoopReplaceableByForEach
186
+ for ( int i = 0 ; i < idsToLoad .length ; i ++ ) {
187
+ final Object id = idsToLoad [i ];
188
+ // found or not, remove the key from the batch-fetch queue
189
+ BatchFetchQueueHelper .removeBatchLoadableEntityKey ( id , getLoadable (), session );
190
+ }
191
+
192
+ final EntityKey entityKey = session .generateEntityKey ( pkValue , getLoadable ().getEntityPersister () );
193
+ //noinspection unchecked
194
+ return (T ) session .getPersistenceContext ().getEntity ( entityKey );
195
+
196
+ } );
196
197
}
197
198
198
199
private void initializeSingleIdLoaderIfNeeded (SharedSessionContractImplementor session ) {
0 commit comments