{"record":{"id":"640244f0fefc6caf","repo":"hibernate/hibernate-orm","slug":"can-t-emulate-on-empty-clause-on-postgresql-640244","errorCode":null,"errorMessage":"Can't emulate on empty clause on PostgreSQL","messagePattern":"Can't emulate on empty clause on PostgreSQL","errorType":"exception","errorClass":"QueryException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/dialect/function/json/PostgreSQLJsonTableFunction.java","lineNumber":146,"sourceCode":"\t\treturn renderColumns( sqlAppender, definition.columns(), clauseLevel, walker );\n\t}\n\n\t@Override\n\tprotected void renderJsonOrdinalityColumnDefinition(SqlAppender sqlAppender, JsonTableOrdinalityColumnDefinition definition, int clauseLevel, SqlAstTranslator<?> walker) {\n\t\tsqlAppender.appendSql( 't' );\n\t\tsqlAppender.appendSql( clauseLevel );\n\t\tsqlAppender.appendSql( \".i \" );\n\t\tsqlAppender.appendSql( definition.name() );\n\t}\n\n\t@Override\n\tprotected void renderJsonValueColumnDefinition(SqlAppender sqlAppender, JsonTableValueColumnDefinition definition, int clauseLevel, SqlAstTranslator<?> walker) {\n\t\t// jsonb_path_query_first errors by default\n\t\tif ( definition.errorBehavior() != null && definition.errorBehavior() != JsonValueErrorBehavior.ERROR ) {\n\t\t\tthrow new QueryException( \"Can't emulate on error clause on PostgreSQL\" );\n\t\t}\n\t\tif ( definition.emptyBehavior() != null && definition.emptyBehavior() != JsonValueEmptyBehavior.NULL ) {\n\t\t\tthrow new QueryException( \"Can't emulate on empty clause on PostgreSQL\" );\n\t\t}\n\t\tfinal String jsonPath = definition.jsonPath() == null\n\t\t\t\t? \"$.\" + definition.name()\n\t\t\t\t: definition.jsonPath();\n\t\tPostgreSQLJsonValueFunction.appendJsonValue(\n\t\t\t\tsqlAppender,\n\t\t\t\tnew ClauseLevelDocumentExpression( clauseLevel ),\n\t\t\t\tnew QueryLiteral<>(\n\t\t\t\t\t\tjsonPath,\n\t\t\t\t\t\twalker.getSessionFactory().getTypeConfiguration().getBasicTypeForJavaType( String.class )\n\t\t\t\t),\n\t\t\t\ttrue,\n\t\t\t\tdefinition.type(),\n\t\t\t\tnull,\n\t\t\t\twalker\n\t\t);\n\t\tsqlAppender.appendSql( ' ' );\n\t\tsqlAppender.appendSql( definition.name() );","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/dialect/function/json/PostgreSQLJsonTableFunction.java#L128-L164","documentation":"Error \"Can't emulate on empty 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 empty 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 empty clause on PostgreSQL.","solutions":["Remove the ON EMPTY 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"}