{"record":{"id":"6d925095933cde36","repo":"hibernate/hibernate-orm","slug":"insert-conflict-do-update-clause-with-constraint-6d9250","errorCode":null,"errorMessage":"Insert conflict 'do update' clause with constraint name is not supported","messagePattern":"Insert conflict 'do update' clause with constraint name is not supported","errorType":"exception","errorClass":"IllegalQueryOperationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/dialect/sql/ast/H2SqlAstTranslator.java","lineNumber":192,"sourceCode":"\t\telse {\n\t\t\tsuper.visitUpdateStatementOnly( statement );\n\t\t}\n\t}\n\n\t@Override\n\tprotected void renderDmlTargetTableExpression(NamedTableReference tableReference) {\n\t\tsuper.renderDmlTargetTableExpression( tableReference );\n\t\tif ( getClauseStack().getCurrent() != Clause.INSERT ) {\n\t\t\trenderTableReferenceIdentificationVariable( tableReference );\n\t\t}\n\t}\n\n\t@Override\n\tprotected void visitConflictClause(ConflictClause conflictClause) {\n\t\tif ( conflictClause != null\n\t\t\t\t&& conflictClause.isDoUpdate()\n\t\t\t\t&& conflictClause.getConstraintName() != null ) {\n\t\t\tthrow new IllegalQueryOperationException(\n\t\t\t\t\t\"Insert conflict 'do update' clause with constraint name is not supported\" );\n\t\t}\n\t}\n\n\t@Override\n\tpublic void visitCteContainer(CteContainer cteContainer) {\n\t\t// H2 has various bugs in different versions that make it impossible to use CTEs with parameters reliably\n\t\twithParameterRenderingMode(\n\t\t\t\tSqlAstNodeRenderingMode.INLINE_PARAMETERS,\n\t\t\t\t() -> super.visitCteContainer( cteContainer )\n\t\t);\n\t}\n\n\t@Override\n\tprotected boolean needsCteInlining() {\n\t\t// CTEs in H2 are just so buggy, that we can't reliably use them\n\t\treturn true;\n\t}","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/dialect/sql/ast/H2SqlAstTranslator.java#L174-L210","documentation":"Error \"Insert conflict 'do update' clause with constraint name is not supported\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown at hibernate-core/src/main/java/org/hibernate/dialect/sql/ast/H2SqlAstTranslator.java:192 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use the primary key as the conflict target instead of a named constraint on H2","Rewrite the upsert using a column-list conflict target"],"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"}