{"record":{"id":"852fa59d753d20bf","repo":"hibernate/hibernate-orm","slug":"mutationquery-cannot-be-treated-as-a-selectionquer","errorCode":null,"errorMessage":"MutationQuery cannot be treated as a SelectionQuery - {}","messagePattern":"MutationQuery cannot be treated as a SelectionQuery - (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/spi/MutationQueryImplementor.java","lineNumber":237,"sourceCode":"\t@Override\n\t@Nonnull\n\t<P> MutationQueryImplementor<T> setConvertedParameter(@Nonnull String name, @Nullable P value, @Nonnull Class<? extends AttributeConverter<P, ?>> converter);\n\n\t@Override\n\t@Nonnull\n\t<P> MutationQueryImplementor<T> setConvertedParameter(int position, @Nullable P value, @Nonnull Class<? extends AttributeConverter<P, ?>> converter);\n\n\n\t// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\t// SelectionQuery stuff\n\n\t@Override\n\t@Deprecated\n\t@SuppressWarnings(\"removal\")\n\t@Nullable\n\tdefault LockModeType getLockMode() {\n\t\t// IllegalStateException is the type required by JPA\n\t\tthrow new IllegalStateException( \"MutationQuery cannot be treated as a SelectionQuery - \" + getMutationString() );\n\t}\n\n\t@Override\n\t@Deprecated\n\t@SuppressWarnings(\"removal\")\n\t@Nonnull\n\tdefault QueryImplementor<T> setLockMode(@Nonnull LockModeType lockMode) {\n\t\t// IllegalStateException is the type required by JPA\n\t\tthrow new IllegalStateException( \"MutationQuery cannot be treated as a SelectionQuery - \" + getMutationString() );\n\t}\n\n\t@Override\n\t@Deprecated\n\t@SuppressWarnings(\"removal\")\n\t@Nonnull\n\tdefault CacheStoreMode getCacheStoreMode() {\n\t\tthrow new IllegalStateException( \"MutationQuery cannot be treated as a SelectionQuery - \" + getMutationString() );\n\t}","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/spi/MutationQueryImplementor.java#L219-L255","documentation":"Error \"MutationQuery cannot be treated as a SelectionQuery - {}\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A selection-only operation is invoked on a mutation (insert/update/delete) query: MutationQuery cannot be treated as a SelectionQuery - <value>","commonSituations":"Calling getResultList()/scroll()/unwrap(SelectionQuery) on a Query created from an update/delete/insert HQL statement, or vice versa.","solutions":["A MutationQuery cannot be used as a SelectionQuery. Use a select query to read results, or executeUpdate() for the mutation."],"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"}