Skip to content

eliminate dependency on useless helper class #2164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.concurrent.TimeUnit;

import org.hibernate.CacheMode;
import org.hibernate.SharedSessionContract;
import org.hibernate.cache.spi.QueryKey;
import org.hibernate.cache.spi.QueryResultsCache;
import org.hibernate.engine.spi.PersistenceContext;
Expand All @@ -20,6 +21,7 @@
import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.query.TupleTransformer;
import org.hibernate.engine.internal.ReactivePersistenceContextAdapter;
import org.hibernate.query.spi.QueryOptions;
import org.hibernate.reactive.sql.exec.spi.ReactiveRowProcessingState;
import org.hibernate.reactive.sql.exec.spi.ReactiveSelectExecutor;
import org.hibernate.reactive.sql.exec.spi.ReactiveValuesResultSet;
Expand All @@ -31,7 +33,6 @@
import org.hibernate.reactive.sql.results.spi.ReactiveRowReader;
import org.hibernate.reactive.sql.results.spi.ReactiveValuesMappingProducer;
import org.hibernate.sql.exec.SqlExecLogger;
import org.hibernate.sql.exec.internal.JdbcExecHelper;
import org.hibernate.sql.exec.internal.StandardStatementCreator;
import org.hibernate.sql.exec.spi.ExecutionContext;
import org.hibernate.sql.exec.spi.JdbcOperationQuerySelect;
Expand All @@ -50,6 +51,8 @@
import org.hibernate.type.descriptor.java.JavaType;
import org.hibernate.type.spi.TypeConfiguration;

import static org.hibernate.internal.util.NullnessHelper.coalesceSuppliedValues;

/**
* @see org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl
*/
Expand Down Expand Up @@ -286,13 +289,13 @@ public CompletionStage<ReactiveValuesResultSet> resolveJdbcValuesSource(
final SessionFactoryImplementor factory = session.getFactory();
final boolean queryCacheEnabled = factory.getSessionFactoryOptions().isQueryCacheEnabled();

final List<?> cachedResults;
final CacheMode cacheMode = JdbcExecHelper.resolveCacheMode( executionContext );
final CacheMode cacheMode = resolveCacheMode( executionContext );
final boolean cacheable = queryCacheEnabled
&& canBeCached
&& executionContext.getQueryOptions().isResultCachingEnabled() == Boolean.TRUE;
final QueryKey queryResultsCacheKey;

final QueryKey queryResultsCacheKey;
final List<?> cachedResults;
if ( cacheable && cacheMode.isGetEnabled() ) {
SqlExecLogger.SQL_EXEC_LOGGER.debugf( "Reading Query result cache data per CacheMode#isGetEnabled [%s]", cacheMode.name() );
final Set<String> querySpaces = jdbcSelect.getAffectedTableNames();
Expand Down Expand Up @@ -419,6 +422,16 @@ public CompletionStage<ReactiveValuesResultSet> resolveJdbcValuesSource(
}
}

private static CacheMode resolveCacheMode(ExecutionContext executionContext) {
final QueryOptions queryOptions = executionContext.getQueryOptions();
final SharedSessionContract session = executionContext.getSession();
return coalesceSuppliedValues(
() -> queryOptions == null ? null : queryOptions.getCacheMode(),
session::getCacheMode,
() -> CacheMode.NORMAL
);
}

/**
* see {@link CachedJdbcValuesMetadata}
*/
Expand Down
Loading