hibernate/hibernate-orm · error · UnsupportedOperationException

Not supported

Error message

Not supported

What it means

ProcedureCallImpl hard-codes isQueryPlanCacheable() to false and throws UnsupportedOperationException from setQueryPlanCacheable(boolean). Stored-procedure calls have no translated plan to cache — each execution builds a JdbcCall from the current parameter registrations — so plan caching is intentionally unavailable on this query type rather than silently ignored.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/procedure/internal/ProcedureCallImpl.java:362

		throw new UnsupportedOperationException( "Fetch profiles not supported for ProcedureCall" );
	}

	@Override @Deprecated
	@SuppressWarnings("removal")
	@Nonnull
	public Query<R> disableFetchProfile(@Nonnull String profileName) {
		throw new UnsupportedOperationException( "Fetch profiles not supported for ProcedureCall" );
	}

	@Override
	public boolean isQueryPlanCacheable() {
		return false;
	}

	@Override
	@Nonnull
	public ProcedureCallImplementor<R> setQueryPlanCacheable(boolean queryPlanCacheable) {
		throw new UnsupportedOperationException( "Not supported" );
	}

	@Override
	@Nonnull
	public ProcedureCallImplementor<R> setTimeout(@Nullable Integer timeout) {
		checkNotClosed();
		if ( timeout == null ) {
			timeout = -1;
		}
		super.setTimeout( timeout );
		return this;
	}

	@Override
	@Nonnull
	public ProcedureCallImplementor<R> setTimeout(int timeout) {
		checkNotClosed();
		super.setTimeout( timeout );

View on GitHub (pinned to fad1729dce)

Solutions

  1. Skip cacheability tuning for ProcedureCall/StoredProcedureQuery instances (instanceof guard).
  2. For HQL queries you are tuning, apply setQueryPlanCacheable on SelectionQuery/MutationQuery only — procedures never plan-cache, so there is nothing to fix for them.

Example fix

// before
query.setQueryPlanCacheable(true); // query is a ProcedureCall -> throws

// after
if (query instanceof org.hibernate.query.SelectionQuery<?> sq) {
    sq.setQueryPlanCacheable(true);
}
Defensive patterns

Strategy: type-guard

Type guard

static boolean supportsPlanCacheToggle(jakarta.persistence.Query q) {
    return q instanceof org.hibernate.query.SelectionQuery
            || q instanceof org.hibernate.query.MutationQuery;
}

Try / catch

try {
    q.setQueryPlanCacheable( true );
} catch (UnsupportedOperationException e) {
    // ProcedureCall is never plan-cached; isQueryPlanCacheable() is fixed to false
}

Prevention

When it happens

Trigger: Calling setQueryPlanCacheable(true) (or false) on a ProcedureCall; bulk tuning code that iterates queries and flips cacheability everywhere.

Common situations: Query-plan-cache investigation/tuning passes applied uniformly to all queries; framework code copying cacheable settings from one query to another.

Related errors


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/4250f540fae94e34. Report an issue: GitHub.