{"record":{"id":"0d0d8e1553e84ab6","repo":"hibernate/hibernate-orm","slug":"expecting-a-delete-or-update-query-but-found","errorCode":null,"errorMessage":"Expecting a delete or update query, but found '{}'","messagePattern":"Expecting a delete or update query, but found '(.+?)'","errorType":"exception","errorClass":"IllegalMutationQueryException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/specification/internal/MutationSpecificationImpl.java","lineNumber":303,"sourceCode":"\t * and produce the corresponding SQM tree.\n\t */\n\t@Nonnull\n\tprivate static <T> SqmDeleteOrUpdateStatement<T> resolveSqmTree(\n\t\t\t@Nonnull String hql,\n\t\t\t@Nonnull QueryEngine queryEngine) {\n\t\tfinal HqlInterpretation<T> hqlInterpretation =\n\t\t\t\tqueryEngine.getInterpretationCache()\n\t\t\t\t\t\t// FIXME : unchecked cast\n\t\t\t\t\t\t.resolveHqlInterpretation( hql, null, queryEngine.getHqlTranslator() );\n\t\tif ( SqmUtil.isRestrictedMutation( hqlInterpretation.getSqmStatement() ) ) {\n\t\t\t// NOTE: this copy is to isolate the actual AST tree from the\n\t\t\t// one stored in the interpretation cache\n\t\t\treturn (SqmDeleteOrUpdateStatement<T>)\n\t\t\t\t\thqlInterpretation.getSqmStatement()\n\t\t\t\t\t\t\t.copy( noParamCopyContext( SqmQuerySource.CRITERIA ) );\n\t\t}\n\t\telse {\n\t\t\tthrow new IllegalMutationQueryException( \"Expecting a delete or update query, but found '\" + hql + \"'\",\n\t\t\t\t\thql );\n\t\t}\n\t}\n\n\t/**\n\t * Used during construction to resolve an incoming named statement reference\n\t * and produce the corresponding SQM tree.\n\t */\n\t@Nonnull\n\tprivate static <T> SqmDeleteOrUpdateStatement<T> resolveSqmTree(\n\t\t\t@Nonnull NamedSqmQueryMemento<?> sqmMemento,\n\t\t\t@Nonnull QueryEngine queryEngine) {\n\t\tfinal var sqmStatement = sqmMemento.getSqmStatement();\n\t\tif ( sqmStatement == null ) {\n\t\t\treturn resolveSqmTree( sqmMemento.getHqlString(), queryEngine );\n\t\t}\n\t\telse if ( SqmUtil.isRestrictedMutation( sqmStatement ) ) {\n\t\t\t//noinspection unchecked","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/specification/internal/MutationSpecificationImpl.java#L285-L321","documentation":"Error \"Expecting a delete or update query, but found '{}'\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A Specification is given a statement of the wrong kind: Expecting a delete or update query, but found '<value>'","commonSituations":"Passing a select statement to MutationSpecification or a mutation statement to SelectionSpecification.","solutions":["A mutation specification requires a delete or update query. Supply an HQL/criteria delete or update statement."],"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"}