{"record":{"id":"1f914aca674458b1","repo":"hibernate/hibernate-orm","slug":"json-path-does-not-end-with-an-array-index-json","errorCode":null,"errorMessage":"JSON path does not end with an array index: ${jsonPath}","messagePattern":"JSON path does not end with an array index: (.+?)","errorType":"exception","errorClass":"QueryException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/dialect/function/json/SQLServerJsonArrayInsertFunction.java","lineNumber":38,"sourceCode":"public class SQLServerJsonArrayInsertFunction extends AbstractJsonArrayInsertFunction {\n\n\tpublic SQLServerJsonArrayInsertFunction(TypeConfiguration typeConfiguration) {\n\t\tsuper( typeConfiguration );\n\t}\n\n\t@Override\n\tpublic void render(\n\t\t\tSqlAppender sqlAppender,\n\t\t\tList<? extends SqlAstNode> arguments,\n\t\t\tReturnableType<?> returnType,\n\t\t\tSqlAstTranslator<?> translator) {\n\t\tfinal String jsonPath = translator.<String>getLiteralValue( (Expression) arguments.get( 1 ) ).trim();\n\t\tfinal int bracketEndIndex = jsonPath.lastIndexOf( ']' );\n\t\tfinal int bracketStartIndex = jsonPath.lastIndexOf( '[' );\n\t\tif ( jsonPath.isEmpty()\n\t\t\t\t|| bracketEndIndex != jsonPath.length() - 1\n\t\t\t\t|| bracketStartIndex == -1 ) {\n\t\t\tthrow new QueryException( \"JSON path does not end with an array index: \" + jsonPath );\n\t\t}\n\t\tfinal int index;\n\t\ttry {\n\t\t\tindex = Integer.parseInt( jsonPath.substring( bracketStartIndex + 1, bracketEndIndex ) );\n\t\t}\n\t\tcatch ( NumberFormatException e ) {\n\t\t\tthrow new QueryException( \"JSON path does not point to a valid array index: \" + jsonPath );\n\t\t}\n\t\tfinal Expression json = (Expression) arguments.get( 0 );\n\t\tfinal SqlAstNode value = arguments.get( 2 );\n\t\t// Only replace data if this is an array\n\t\tsqlAppender.appendSql( \"(select case when left(json_query(x.d,x.p),1)='[' then \" );\n\t\t// Replace the array\n\t\tsqlAppender.appendSql( \"json_modify(x.d,x.p,json_query((\" );\n\t\t// Aggregate a new JSON array based on element rows\n\t\tsqlAppender.appendSql( \"select '['+string_agg(t.v,',') within group (order by t.k)+']' from (\" );\n\n\t\tsqlAppender.appendSql( \"select x.i k,x.v v union all \" );","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/dialect/function/json/SQLServerJsonArrayInsertFunction.java#L20-L56","documentation":"Error \"JSON path does not end with an array index: ${jsonPath}\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Triggered when the application calls a Hibernate dialect feature that the configured database dialect cannot provide: JSON path does not end with an array index (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: JSON path does not end with an array index (SQL Server).","solutions":["End the JSON path with an array index, e.g. '$.a[0]'."],"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"}