hibernate/hibernate-orm · error · IllegalSelectQueryException

Not a select query

Error message

Not a select query

What it means

Error "Not a select query" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/query/spi/MutationQueryImplementor.java:443

	@Override @Deprecated
	@Nonnull
	MutationQueryImplementor<T> setParameter(int position, @Nullable Calendar value, @Nonnull TemporalType temporalType);

	@Override @Deprecated
	@Nonnull
	MutationQueryImplementor<T> setParameter(@Nonnull Parameter<Calendar> param, @Nullable Calendar value, @Nonnull TemporalType temporalType);

	@Override @Deprecated
	@Nonnull
	MutationQueryImplementor<T> setParameter(@Nonnull Parameter<Date> param, @Nullable Date value, @Nonnull TemporalType temporalType);

	// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// SelectionQuery Handling

	@Override
	@Nonnull
	default SelectionQueryImplementor<T> asSelectionQuery() {
		throw new IllegalSelectQueryException( "Not a select query", getQueryString() );
	}

	@Override
	@Nonnull
	default <X> SelectionQueryImplementor<X> asSelectionQuery(Class<X> type) {
		throw new IllegalSelectQueryException( "Not a select query", getQueryString() );
	}

	@Override
	@Nonnull
	default <X> SelectionQueryImplementor<X> asSelectionQuery(EntityGraph<X> entityGraph) {
		throw new IllegalSelectQueryException( "Not a select query", getQueryString() );
	}

	@Override
	@Nonnull
	default <X> SelectionQueryImplementor<X> asSelectionQuery(EntityGraph<X> entityGraph, GraphSemantic graphSemantic) {
		throw new IllegalSelectQueryException( "Not a select query", getQueryString() );

View on GitHub (pinned to fad1729dce)

Solutions

  1. The query is not a select query. Use a selection query where results are read.

When it happens

Trigger: A query is treated as the wrong kind (selection vs mutation): Not a select query

Common situations: Unwrapping/casting a SelectionQuery to MutationQuery (or the reverse) when the underlying statement type does not match.


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