Skip to content

Commit ae470b7

Browse files
committed
HHH-19526 Avoid generating a QueryInterpretationCache.Key when the query cache is disabled
1 parent 6c573e9 commit ae470b7

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

hibernate-core/src/main/java/org/hibernate/query/sqm/internal/QuerySqmImpl.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,10 +490,16 @@ public boolean isQueryPlanCacheable() {
490490
}
491491

492492
private SelectQueryPlan<R> resolveSelectQueryPlan() {
493-
final QueryInterpretationCache.Key cacheKey = createInterpretationsKey( this );
494-
return cacheKey != null
495-
? interpretationCache().resolveSelectQueryPlan( cacheKey, this::buildSelectQueryPlan )
496-
: buildSelectQueryPlan();
493+
final QueryInterpretationCache queryCache = interpretationCache();
494+
if ( queryCache.isEnabled() ) {
495+
final QueryInterpretationCache.Key cacheKey = createInterpretationsKey( this );
496+
return cacheKey != null
497+
? queryCache.resolveSelectQueryPlan( cacheKey, this::buildSelectQueryPlan )
498+
: buildSelectQueryPlan();
499+
}
500+
else {
501+
return buildSelectQueryPlan();
502+
}
497503
}
498504

499505
private QueryInterpretationCache interpretationCache() {

0 commit comments

Comments
 (0)