Skip to content

Commit d4740a9

Browse files
committed
some very minor cleanups
Signed-off-by: Gavin King <gavin@hibernate.org>
1 parent afca931 commit d4740a9

File tree

2 files changed

+30
-90
lines changed

2 files changed

+30
-90
lines changed

hibernate-core/src/main/java/org/hibernate/sql/exec/spi/JdbcSelectExecutor.java

Lines changed: 21 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,6 @@
4141
@Incubating
4242
public interface JdbcSelectExecutor {
4343

44-
/**
45-
* @since 6.4
46-
* @deprecated Use {@link #executeQuery(JdbcOperationQuerySelect, JdbcParameterBindings, ExecutionContext, RowTransformer, Class, StatementCreator, ResultsConsumer)} instead
47-
*/
48-
@Deprecated(forRemoval = true, since = "6.6")
49-
default <T, R> T executeQuery(
50-
JdbcOperationQuerySelect jdbcSelect,
51-
JdbcParameterBindings jdbcParameterBindings,
52-
ExecutionContext executionContext,
53-
RowTransformer<R> rowTransformer,
54-
Class<R> domainResultType,
55-
Function<String, PreparedStatement> statementCreator,
56-
ResultsConsumer<T, R> resultsConsumer) {
57-
return executeQuery(
58-
jdbcSelect,
59-
jdbcParameterBindings,
60-
executionContext,
61-
rowTransformer,
62-
domainResultType,
63-
(executionContext1, sql) -> statementCreator.apply( sql ),
64-
resultsConsumer
65-
);
66-
}
67-
6844
/**
6945
* @since 6.6
7046
*/
@@ -213,8 +189,9 @@ interface StatementCreator {
213189
}
214190

215191
/*
216-
When `Query#scroll()` is call the query is not executed immediately, a new ExecutionContext with the values of the `persistenceContext.isDefaultReadOnly()` and of the `queryOptions.isReadOnly()`
217-
set at the moment of the Query#scroll() call is created in order to use it when the query will be executed.
192+
When `Query#scroll()` is call the query is not executed immediately, a new ExecutionContext with the values
193+
of the `persistenceContext.isDefaultReadOnly()` and of the `queryOptions.isReadOnly()` set at the moment of
194+
the Query#scroll() call is created in order to use it when the query will be executed.
218195
*/
219196
private ExecutionContext getScrollContext(ExecutionContext context) {
220197
class ScrollableExecutionContext extends BaseExecutionContext implements QueryOptions {
@@ -388,45 +365,25 @@ public Set<String> getDisabledFetchProfiles() {
388365
}
389366
}
390367

391-
final QueryOptions queryOptions = context.getQueryOptions();
392-
final Boolean readOnly;
393-
if ( queryOptions.isReadOnly() == null ) {
394-
readOnly = context.getSession().getPersistenceContext().isDefaultReadOnly();
395-
}
396-
else {
397-
readOnly = queryOptions.isReadOnly();
398-
}
399-
final Integer timeout = queryOptions.getTimeout();
400-
final FlushMode flushMode = queryOptions.getFlushMode();
401-
final AppliedGraph appliedGraph = queryOptions.getAppliedGraph();
402-
final TupleTransformer<?> tupleTransformer = queryOptions.getTupleTransformer();
403-
final ResultListTransformer<?> resultListTransformer = queryOptions.getResultListTransformer();
404-
final Boolean resultCachingEnabled = queryOptions.isResultCachingEnabled();
405-
final CacheRetrieveMode cacheRetrieveMode = queryOptions.getCacheRetrieveMode();
406-
final CacheStoreMode cacheStoreMode = queryOptions.getCacheStoreMode();
407-
final String resultCacheRegionName = queryOptions.getResultCacheRegionName();
408-
final LockOptions lockOptions = queryOptions.getLockOptions();
409-
final String comment = queryOptions.getComment();
410-
final List<String> databaseHints = queryOptions.getDatabaseHints();
411-
final Integer fetchSize = queryOptions.getFetchSize();
412-
final Limit limit = queryOptions.getLimit();
413-
368+
final QueryOptions options = context.getQueryOptions();
414369
return new ScrollableExecutionContext(
415-
timeout,
416-
flushMode,
417-
readOnly,
418-
appliedGraph,
419-
tupleTransformer,
420-
resultListTransformer,
421-
resultCachingEnabled,
422-
cacheRetrieveMode,
423-
cacheStoreMode,
424-
resultCacheRegionName,
425-
lockOptions,
426-
comment,
427-
databaseHints,
428-
fetchSize,
429-
limit,
370+
options.getTimeout(),
371+
options.getFlushMode(),
372+
options.isReadOnly() == null
373+
? context.getSession().getPersistenceContext().isDefaultReadOnly()
374+
: options.isReadOnly(),
375+
options.getAppliedGraph(),
376+
options.getTupleTransformer(),
377+
options.getResultListTransformer(),
378+
options.isResultCachingEnabled(),
379+
options.getCacheRetrieveMode(),
380+
options.getCacheStoreMode(),
381+
options.getResultCacheRegionName(),
382+
options.getLockOptions(),
383+
options.getComment(),
384+
options.getDatabaseHints(),
385+
options.getFetchSize(),
386+
options.getLimit(),
430387
context
431388
);
432389
}

hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesSourceProcessingStateStandardImpl.java

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,16 @@
1010
import java.util.HashMap;
1111
import java.util.List;
1212
import java.util.Map;
13-
import java.util.function.Consumer;
1413

1514
import org.hibernate.engine.spi.CollectionKey;
1615
import org.hibernate.engine.spi.EntityHolder;
1716
import org.hibernate.engine.spi.SharedSessionContractImplementor;
1817
import org.hibernate.event.spi.EventSource;
1918
import org.hibernate.event.spi.PostLoadEvent;
2019
import org.hibernate.event.spi.PreLoadEvent;
21-
import org.hibernate.internal.CoreLogging;
22-
import org.hibernate.internal.CoreMessageLogger;
2320
import org.hibernate.query.spi.QueryOptions;
2421
import org.hibernate.sql.exec.spi.ExecutionContext;
25-
import org.hibernate.sql.results.graph.collection.CollectionInitializer;
2622
import org.hibernate.sql.results.graph.collection.LoadingCollectionEntry;
27-
import org.hibernate.sql.results.graph.collection.internal.ArrayInitializer;
2823
import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions;
2924
import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingState;
3025

@@ -33,8 +28,6 @@
3328
*/
3429
public class JdbcValuesSourceProcessingStateStandardImpl implements JdbcValuesSourceProcessingState {
3530

36-
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( JdbcValuesSourceProcessingStateStandardImpl.class );
37-
3831
private final ExecutionContext executionContext;
3932
private final JdbcValuesSourceProcessingOptions processingOptions;
4033

@@ -115,11 +108,7 @@ public List<EntityHolder> getReloadedEntityHolders() {
115108

116109
@Override
117110
public LoadingCollectionEntry findLoadingCollectionLocally(CollectionKey key) {
118-
if ( loadingCollectionMap == null ) {
119-
return null;
120-
}
121-
122-
return loadingCollectionMap.get( key );
111+
return loadingCollectionMap == null ? null : loadingCollectionMap.get( key );
123112
}
124113

125114
@Override
@@ -141,27 +130,21 @@ public void finishUp(boolean registerSubselects) {
141130
// now we can finalize loading collections
142131
finishLoadingCollections();
143132

144-
final Consumer<EntityHolder> holderConsumer;
145-
if ( registerSubselects ) {
146-
holderConsumer = executionContext::registerLoadingEntityHolder;
147-
}
148-
else {
149-
holderConsumer = null;
150-
}
151-
executionContext.getSession().getPersistenceContextInternal().postLoad( this, holderConsumer );
133+
getSession().getPersistenceContextInternal()
134+
.postLoad( this,
135+
registerSubselects ? executionContext::registerLoadingEntityHolder : null );
152136
}
153137

154-
@SuppressWarnings("SimplifiableIfStatement")
155138
private boolean isReadOnly() {
156139
if ( getQueryOptions().isReadOnly() != null ) {
157140
return getQueryOptions().isReadOnly();
158141
}
159-
160-
if ( executionContext.getSession() instanceof EventSource ) {
161-
return executionContext.getSession().isDefaultReadOnly();
142+
else if ( getSession() instanceof EventSource ) {
143+
return getSession().isDefaultReadOnly();
144+
}
145+
else {
146+
return false;
162147
}
163-
164-
return false;
165148
}
166149

167150

0 commit comments

Comments
 (0)