{"record":{"id":"2bb3dd275feeee13","repo":"hibernate/hibernate-orm","slug":"mutationquery-cannot-be-treated-as-a-selectionquer-2bb3dd","errorCode":null,"errorMessage":"MutationQuery cannot be treated as a SelectionQuery - ${mutationString}","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":287,"sourceCode":"\t@Nonnull\n\tdefault CacheRetrieveMode getCacheRetrieveMode() {\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> setCacheRetrieveMode(@Nonnull CacheRetrieveMode cacheRetrieveMode) {\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\tdefault int getMaxResults() {\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> setMaxResults(int maxResults) {\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\tdefault int getFirstResult() {\n\t\tthrow new IllegalStateException( \"MutationQuery cannot be treated as a SelectionQuery - \" + getMutationString() );\n\t}\n","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/spi/MutationQueryImplementor.java#L269-L305","documentation":"Error \"MutationQuery cannot be treated as a SelectionQuery - ${mutationString}\" 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 for the given statement. Use a selection query instead."],"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"}