{"record":{"id":"51d6ec20b07dfbc5","repo":"hibernate/hibernate-orm","slug":"can-t-emulate-exists-false-on-error-for-json-table","errorCode":null,"errorMessage":"Can't emulate exists false on error for json_table() on SQL Server","messagePattern":"Can't emulate exists false on error for json_table\\(\\) on SQL Server","errorType":"exception","errorClass":"QueryException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/dialect/function/json/SQLServerJsonTableFunction.java","lineNumber":158,"sourceCode":"\t\t\t\tif ( queryColumnDefinition.wrapMode() == JsonQueryWrapMode.WITH_WRAPPER ) {\n\t\t\t\t\tsqlAppender.appendSql( \"+']'\" );\n\t\t\t\t}\n\t\t\t\tif ( queryColumnDefinition.emptyBehavior() == JsonQueryEmptyBehavior.EMPTY_ARRAY ) {\n\t\t\t\t\tsqlAppender.appendSql( \",'[]')\" );\n\t\t\t\t}\n\t\t\t\telse if ( queryColumnDefinition.emptyBehavior() == JsonQueryEmptyBehavior.EMPTY_OBJECT ) {\n\t\t\t\t\tsqlAppender.appendSql( \",'{}')\" );\n\t\t\t\t}\n\t\t\t\tsqlAppender.appendSql( ' ' );\n\t\t\t\tsqlAppender.appendSql( queryColumnDefinition.name() );\n\t\t\t}\n\t\t\telse if ( columnDefinition instanceof JsonTableOrdinalityColumnDefinition ordinalityColumnDefinition ) {\n\t\t\t\tsqlAppender.appendSql( \"row_number() over (order by (select null)) \" );\n\t\t\t\tsqlAppender.appendSql( ordinalityColumnDefinition.name() );\n\t\t\t}\n\t\t\telse if ( columnDefinition instanceof JsonTableExistsColumnDefinition existsColumnDefinition ) {\n\t\t\t\tif ( existsColumnDefinition.errorBehavior() == JsonExistsErrorBehavior.FALSE ) {\n\t\t\t\t\tthrow new QueryException( \"Can't emulate exists false on error for json_table() on SQL Server\" );\n\t\t\t\t}\n\t\t\t\tfinal String jsonPath = existsColumnDefinition.jsonPath() == null\n\t\t\t\t\t\t? \"$.\" + existsColumnDefinition.name()\n\t\t\t\t\t\t: existsColumnDefinition.jsonPath();\n\t\t\t\tfinal List<JsonPathHelper.JsonPathElement> pathElements = JsonPathHelper.parseJsonPathElements( jsonPath );\n\t\t\t\tfinal JsonPathHelper.JsonPathElement lastPathElement = pathElements.get( pathElements.size() - 1 );\n\t\t\t\tfinal String prefix = JsonPathHelper.toJsonPath( pathElements, 0, pathElements.size() - 1 );\n\t\t\t\tfinal String terminalKey;\n\t\t\t\tif ( lastPathElement instanceof JsonPathHelper.JsonIndexAccess indexAccess ) {\n\t\t\t\t\tterminalKey = String.valueOf( indexAccess.index() );\n\t\t\t\t}\n\t\t\t\telse if (lastPathElement instanceof JsonPathHelper.JsonAttribute attribute) {\n\t\t\t\t\tterminalKey = attribute.attribute();\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthrow new AssertionFailure( \"Unrecognized json path element: \" + lastPathElement );\n\t\t\t\t}\n","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/dialect/function/json/SQLServerJsonTableFunction.java#L140-L176","documentation":"Error \"Can't emulate exists false on error for json_table() on SQL Server\" 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 exists false on error for json_table() on SQL Server.","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 exists false on error for json_table() on SQL Server.","solutions":["Remove the FALSE ON ERROR clause from the json_table exists column."],"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"}