{"record":{"id":"1b18216353ff0912","repo":"hibernate/hibernate-orm","slug":"can-t-emulate-on-error-clause-on-postgresql","errorCode":null,"errorMessage":"Can't emulate on error clause on PostgreSQL","messagePattern":"Can't emulate on error clause on PostgreSQL","errorType":"exception","errorClass":"QueryException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/dialect/function/json/PostgreSQLJsonExistsFunction.java","lineNumber":36,"sourceCode":"\n/**\n * PostgreSQL json_exists function.\n */\npublic class PostgreSQLJsonExistsFunction extends JsonExistsFunction {\n\n\tpublic PostgreSQLJsonExistsFunction(TypeConfiguration typeConfiguration) {\n\t\tsuper( typeConfiguration, true, true );\n\t}\n\n\t@Override\n\tprotected void render(\n\t\t\tSqlAppender sqlAppender,\n\t\t\tJsonExistsArguments arguments,\n\t\t\tReturnableType<?> returnType,\n\t\t\tSqlAstTranslator<?> walker) {\n\t\t// jsonb_path_exists errors by default\n\t\tif ( arguments.errorBehavior() != null && arguments.errorBehavior() != JsonExistsErrorBehavior.ERROR ) {\n\t\t\tthrow new QueryException( \"Can't emulate on error clause on PostgreSQL\" );\n\t\t}\n\t\tappendJsonExists( sqlAppender, walker, arguments.jsonDocument(), arguments.jsonPath(), arguments.passingClause() );\n\t}\n\n\tstatic void appendJsonExists(SqlAppender sqlAppender, SqlAstTranslator<?> walker, Expression jsonDocument, Expression jsonPath, @Nullable JsonPathPassingClause passingClause) {\n\t\tsqlAppender.appendSql( \"jsonb_path_exists(\" );\n\t\tjsonDocument.accept( walker );\n\t\tsqlAppender.appendSql( ',' );\n\t\tjsonPath.accept( walker );\n\t\tif ( passingClause != null ) {\n\t\t\tsqlAppender.append( \",jsonb_build_object\" );\n\t\t\tchar separator = '(';\n\t\t\tfor ( Map.Entry<String, Expression> entry : passingClause.getPassingExpressions().entrySet() ) {\n\t\t\t\tsqlAppender.append( separator );\n\t\t\t\tsqlAppender.appendSingleQuoteEscapedString( entry.getKey() );\n\t\t\t\tsqlAppender.append( ',' );\n\t\t\t\tentry.getValue().accept( walker );\n\t\t\t\tseparator = ',';","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/dialect/function/json/PostgreSQLJsonExistsFunction.java#L18-L54","documentation":"Error \"Can't emulate on error clause on PostgreSQL\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Triggered when the application calls a Hibernate dialect feature that the configured database dialect cannot provide: Can't emulate on error clause on PostgreSQL.","commonSituations":"Common when running against a database whose dialect lacks this capability, when a mapping or HQL/Criteria query requests unsupported functionality, or when the wrong dialect is configured for the database in use. Error: Can't emulate on error clause on PostgreSQL.","solutions":["Remove the ON ERROR clause for PostgreSQL."],"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"}