hibernate/hibernate-orm · error · IllegalStateException

Cache retrieval not supported

Error message

Cache retrieval not supported

What it means

Error "Cache retrieval not supported" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/query/internal/AbstractQuery.java:440

	@Override
	@SuppressWarnings("removal")
	@Nullable
	public String getCacheRegion() {
		return queryOptions.getResultCacheRegionName();
	}

	@Override
	@SuppressWarnings("removal")
	public Query<T> setCacheRegion(@Nullable String cacheRegion) {
		verifySelectionOption( "Result caching" );
		queryOptions.setResultCacheRegionName( cacheRegion );
		return this;
	}

	@Override
	@Nonnull
	public CacheRetrieveMode getCacheRetrieveMode() {
		throw new IllegalStateException( "Cache retrieval not supported" );
	}

	@Override
	@Nonnull
	public QueryImplementor<T> setCacheRetrieveMode(@Nonnull CacheRetrieveMode cacheRetrieveMode) {
		verifySelectionOption( "Result caching" );
		super.setCacheRetrieveMode( cacheRetrieveMode );
		return this;
	}

	@Override
	@Nonnull
	public CacheStoreMode getCacheStoreMode() {
		throw new IllegalStateException( "Cache storage not supported" );
	}

	@Override
	@Nonnull

View on GitHub (pinned to fad1729dce)

Solutions

  1. Cache retrieval (CacheRetrieveMode) is not supported for this query kind. Do not set a cache retrieve mode here.

When it happens

Trigger: Query caching is used in an unsupported way: Cache retrieval not supported

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/42244fc147d936db. Report an issue: GitHub.