|
12 | 12 | import java.util.concurrent.TimeUnit; |
13 | 13 |
|
14 | 14 | import org.hibernate.CacheMode; |
| 15 | +import org.hibernate.SharedSessionContract; |
15 | 16 | import org.hibernate.cache.spi.QueryKey; |
16 | 17 | import org.hibernate.cache.spi.QueryResultsCache; |
17 | 18 | import org.hibernate.engine.spi.PersistenceContext; |
|
20 | 21 | import org.hibernate.internal.util.collections.ArrayHelper; |
21 | 22 | import org.hibernate.query.TupleTransformer; |
22 | 23 | import org.hibernate.engine.internal.ReactivePersistenceContextAdapter; |
| 24 | +import org.hibernate.query.spi.QueryOptions; |
23 | 25 | import org.hibernate.reactive.sql.exec.spi.ReactiveRowProcessingState; |
24 | 26 | import org.hibernate.reactive.sql.exec.spi.ReactiveSelectExecutor; |
25 | 27 | import org.hibernate.reactive.sql.exec.spi.ReactiveValuesResultSet; |
|
31 | 33 | import org.hibernate.reactive.sql.results.spi.ReactiveRowReader; |
32 | 34 | import org.hibernate.reactive.sql.results.spi.ReactiveValuesMappingProducer; |
33 | 35 | import org.hibernate.sql.exec.SqlExecLogger; |
34 | | -import org.hibernate.sql.exec.internal.JdbcExecHelper; |
35 | 36 | import org.hibernate.sql.exec.internal.StandardStatementCreator; |
36 | 37 | import org.hibernate.sql.exec.spi.ExecutionContext; |
37 | 38 | import org.hibernate.sql.exec.spi.JdbcOperationQuerySelect; |
|
50 | 51 | import org.hibernate.type.descriptor.java.JavaType; |
51 | 52 | import org.hibernate.type.spi.TypeConfiguration; |
52 | 53 |
|
| 54 | +import static org.hibernate.internal.util.NullnessHelper.coalesceSuppliedValues; |
| 55 | + |
53 | 56 | /** |
54 | 57 | * @see org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl |
55 | 58 | */ |
@@ -286,13 +289,13 @@ public CompletionStage<ReactiveValuesResultSet> resolveJdbcValuesSource( |
286 | 289 | final SessionFactoryImplementor factory = session.getFactory(); |
287 | 290 | final boolean queryCacheEnabled = factory.getSessionFactoryOptions().isQueryCacheEnabled(); |
288 | 291 |
|
289 | | - final List<?> cachedResults; |
290 | | - final CacheMode cacheMode = JdbcExecHelper.resolveCacheMode( executionContext ); |
| 292 | + final CacheMode cacheMode = resolveCacheMode( executionContext ); |
291 | 293 | final boolean cacheable = queryCacheEnabled |
292 | 294 | && canBeCached |
293 | 295 | && executionContext.getQueryOptions().isResultCachingEnabled() == Boolean.TRUE; |
294 | | - final QueryKey queryResultsCacheKey; |
295 | 296 |
|
| 297 | + final QueryKey queryResultsCacheKey; |
| 298 | + final List<?> cachedResults; |
296 | 299 | if ( cacheable && cacheMode.isGetEnabled() ) { |
297 | 300 | SqlExecLogger.SQL_EXEC_LOGGER.debugf( "Reading Query result cache data per CacheMode#isGetEnabled [%s]", cacheMode.name() ); |
298 | 301 | final Set<String> querySpaces = jdbcSelect.getAffectedTableNames(); |
@@ -419,6 +422,16 @@ public CompletionStage<ReactiveValuesResultSet> resolveJdbcValuesSource( |
419 | 422 | } |
420 | 423 | } |
421 | 424 |
|
| 425 | + private static CacheMode resolveCacheMode(ExecutionContext executionContext) { |
| 426 | + final QueryOptions queryOptions = executionContext.getQueryOptions(); |
| 427 | + final SharedSessionContract session = executionContext.getSession(); |
| 428 | + return coalesceSuppliedValues( |
| 429 | + () -> queryOptions == null ? null : queryOptions.getCacheMode(), |
| 430 | + session::getCacheMode, |
| 431 | + () -> CacheMode.NORMAL |
| 432 | + ); |
| 433 | + } |
| 434 | + |
422 | 435 | /** |
423 | 436 | * see {@link CachedJdbcValuesMetadata} |
424 | 437 | */ |
|
0 commit comments