hibernate/hibernate-orm · error · IllegalSelectQueryException
Not a mutation query
Error message
Not a mutation query
What it means
Error "Not a mutation query" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java:732
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
public NativeQueryImplementor<R> setTimeout(@Nullable Timeout timeout) {
super.setTimeout( timeout );
return this;
}
@Override
@NullableView on GitHub (pinned to fad1729dce)
Solutions
- The method was called on a SELECT native query but requires a mutation (INSERT/UPDATE/DELETE) query.
- Use createNativeMutationQuery / a DML statement, or use getResultList() for selects.
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/9aa8926b453a022f.
Report an issue: GitHub.