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/sql/internal/NativeQueryImpl.java:725

	@Nonnull
	public QueryParameterBindings getParameterBindings() {
		return getQueryParameterBindings();
	}

	@Override
	public Class<R> getResultType() {
		errorIfNotSelectForSure();
		return resultType;
	}

	private boolean isNotSelectForSure() {
		return isSelectQuery() == Boolean.FALSE;
	}

	private void errorIfNotSelectForSure() {
		if ( isNotSelectForSure() ) {
			// we unequivocally know it IS NOT a select query
			throw new IllegalSelectQueryException( "Not a select query", sqlString );
		}
	}

	private void errorIfSelectForSure() {
		if ( isSelectQuery() == Boolean.TRUE ) {
			// we unequivocally know it IS a select query
			throw new IllegalSelectQueryException( "Not a mutation query", sqlString );
		}
	}

	@Override
	@Nullable
	public Class<R> getTargetType() {
		return resultType;
	}

	@Override
	@Nonnull

View on GitHub (pinned to fad1729dce)

Solutions

  1. The method was called on a mutation native query but requires a SELECT query.
  2. Use a SELECT native query, or use executeUpdate() for mutation queries.

When it happens

Trigger: A query object is used through an interface or role it does not implement.

Common situations: Casting or unwrapping a native/HQL, select/mutation query to the wrong type, or passing a non-property path where one is required.


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