{"record":{"id":"9aa8926b453a022f","repo":"hibernate/hibernate-orm","slug":"not-a-mutation-query-9aa892","errorCode":null,"errorMessage":"Not a mutation query","messagePattern":"Not a mutation query","errorType":"exception","errorClass":"IllegalSelectQueryException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java","lineNumber":732,"sourceCode":"\t\terrorIfNotSelectForSure();\n\t\treturn resultType;\n\t}\n\n\tprivate boolean isNotSelectForSure() {\n\t\treturn isSelectQuery() == Boolean.FALSE;\n\t}\n\n\tprivate void errorIfNotSelectForSure() {\n\t\tif ( isNotSelectForSure() ) {\n\t\t\t// we unequivocally know it IS NOT a select query\n\t\t\tthrow new IllegalSelectQueryException( \"Not a select query\", sqlString );\n\t\t}\n\t}\n\n\tprivate void errorIfSelectForSure() {\n\t\tif ( isSelectQuery() == Boolean.TRUE ) {\n\t\t\t// we unequivocally know it IS a select query\n\t\t\tthrow new IllegalSelectQueryException( \"Not a mutation query\", sqlString );\n\t\t}\n\t}\n\n\t@Override\n\t@Nullable\n\tpublic Class<R> getTargetType() {\n\t\treturn resultType;\n\t}\n\n\t@Override\n\t@Nonnull\n\tpublic NativeQueryImplementor<R> setTimeout(@Nullable Timeout timeout) {\n\t\tsuper.setTimeout( timeout );\n\t\treturn this;\n\t}\n\n\t@Override\n\t@Nullable","sourceCodeStart":714,"sourceCodeEnd":750,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java#L714-L750","documentation":"Error \"Not a mutation query\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A query object is used through an interface or role it does not implement.","commonSituations":"Casting or unwrapping a native/HQL, select/mutation query to the wrong type, or passing a non-property path where one is required.","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."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}