{"record":{"id":"30125a3e738e0e04","repo":"hibernate/hibernate-orm","slug":"insert-conflict-do-update-clause-with-constraint-30125a","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/DB2SqlAstTranslator.java","lineNumber":386,"sourceCode":"\tprotected void visitInsertStatementOnly(InsertSelectStatement statement) {\n\t\tfinal boolean closeWrapper = renderReturningClause( statement );\n\t\tif ( statement.getConflictClause() == null || statement.getConflictClause().isDoNothing() ) {\n\t\t\t// Render plain insert statement and possibly run into unique constraint violation\n\t\t\tsuper.visitInsertStatementOnly( statement );\n\t\t}\n\t\telse {\n\t\t\tvisitInsertStatementEmulateMerge( statement );\n\t\t}\n\t\tif ( closeWrapper ) {\n\t\t\tappendSql( ')' );\n\t\t}\n\t}\n\n\t@Override\n\tprotected void visitConflictClause(ConflictClause conflictClause) {\n\t\tif ( conflictClause != null ) {\n\t\t\tif ( conflictClause.isDoUpdate() && conflictClause.getConstraintName() != null ) {\n\t\t\t\tthrow new IllegalQueryOperationException( \"Insert conflict 'do update' clause with constraint name is not supported\" );\n\t\t\t}\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 renderFromClauseAfterUpdateSet(UpdateStatement statement) {\n\t\trenderFromClauseExcludingDmlTargetReference( statement );\n\t}\n\n\tprotected boolean renderReturningClause(MutationStatement statement) {","sourceCodeStart":368,"sourceCodeEnd":404,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/dialect/sql/ast/DB2SqlAstTranslator.java#L368-L404","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/DB2SqlAstTranslator.java:386 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use an insert-conflict 'do update' clause keyed on the primary key instead of a named constraint on DB2","Specify the conflict target by column list rather than constraint name"],"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"}