hibernate/hibernate-orm · error · UnsupportedOperationException

EntityGraphs are not supported for native queries

Error message

EntityGraphs are not supported for native queries

What it means

Error "EntityGraphs are not supported for native queries" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java:1703

	@Override
	@Nonnull
	public NativeQueryImplementor<R> setComment(@Nullable String comment) {
		super.setComment( comment );
		return this;
	}

	@Override
	@Nonnull
	public NativeQueryImplementor<R> addQueryHint(@Nonnull String hint) {
		super.addQueryHint( hint );
		return this;
	}

	@Override @Deprecated
	@Nonnull
	public NativeQueryImplementor<R> setEntityGraph(@Nonnull EntityGraph<? super R> entityGraph) {
		throw new UnsupportedOperationException( "EntityGraphs are not supported for native queries" );
	}

	@Override @Deprecated
	@SuppressWarnings("removal")
	@Nonnull
	public NativeQueryImplementor<R> setEntityGraph(@Nonnull EntityGraph<? super R> graph, @Nonnull GraphSemantic semantic) {
		throw new UnsupportedOperationException( "EntityGraphs are not supported for native queries" );
	}

	@Override
	protected void collectHints(Map<String, Object> hints) {
		super.collectHints( hints );
		//noinspection removal
		putIfNotNull( hints, HINT_NATIVE_LOCK_MODE, queryOptions.getLockOptions().getLockMode() );
	}

	protected void applySynchronizeSpacesHint(Object value) {
		applySynchronizeSpace( value );

View on GitHub (pinned to fad1729dce)

Solutions

  1. EntityGraphs are not supported for native queries.
  2. Remove the EntityGraph application, or use an HQL/criteria query.

When it happens

Trigger: An API operation is invoked on a query object that does not support it.

Common situations: Calling query hint, locking, pagination, conversion, or mutation APIs on a query kind (native vs HQL, select vs mutation) that does not implement them.


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