hibernate/hibernate-orm · error · IllegalStateException
Query result set caching disallowed for historical query
Error message
Query result set caching disallowed for historical query
What it means
IllegalStateException guard in the hint dispatcher: the jakarta.persistence.cache.retrieveMode (or related caching hint) was applied to a historical/query that disallows result-set caching.
Solutions
- Result-set caching cannot be used with a historical (audit) query. Remove setCacheable(true) / the cache hint from the historical query.
Defensive patterns
Strategy: validation
When it happens
Trigger: Query caching is used in an unsupported way: Query result set caching disallowed for historical query
Common situations: Enabling result-set caching on historical (audit) queries, or using cache modes the query does not support.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/db75eba42cb4d152.
Report an issue: GitHub.
Appendix: source
Thrown at hibernate-core/src/main/java/org/hibernate/query/internal/AbstractCommonQueryContract.java:535
case HINT_QUERY_DATABASE:
queryOptions.addDatabaseHint( (String) value );
return true;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// sometimes relevant
case HINT_QUERY_PLAN_CACHEABLE:
applyQueryPlanCachingHint( hintName, value );
case HINT_READ_ONLY:
applyReadOnlyHint( hintName, value );
return true;
case HINT_FETCH_SIZE:
applyFetchSizeHint( hintName, value );
return true;
case HINT_LIMIT_IN_MEMORY:
queryOptions.setLimitInMemory( getBoolean( value ) );
return true;
case HINT_CACHEABLE:
if ( isHistorical() ) {
throw new IllegalStateException( "Query result set caching disallowed for historical query" );
}
applyResultCachingHint( hintName, value );
return true;
case HINT_CACHE_REGION:
queryOptions.setResultCacheRegionName( (String) value );
return true;
case HINT_CACHE_MODE:
applyResultCacheModeHint( hintName, value );
return true;
case HINT_JAVAEE_CACHE_RETRIEVE_MODE:
DEPRECATION_LOGGER.deprecatedHint( HINT_JAVAEE_CACHE_RETRIEVE_MODE, HINT_SPEC_CACHE_RETRIEVE_MODE );
//fall through to:
case HINT_SPEC_CACHE_RETRIEVE_MODE:
applyResultCachingRetrieveModeHint( hintName, value );
return true;
case HINT_JAVAEE_CACHE_STORE_MODE:
DEPRECATION_LOGGER.deprecatedHint( HINT_JAVAEE_CACHE_STORE_MODE, HINT_SPEC_CACHE_STORE_MODE );
//fall through to:View on GitHub (pinned to fad1729dce)