{"record":{"id":"d2d387265770050f","repo":"hibernate/hibernate-orm","slug":"json-path-uses-parameter-that-is-not-pas","errorCode":null,"errorMessage":"JSON path [{}] uses parameter [{}] that is not passed","messagePattern":"JSON path \\[(.+?)\\] uses parameter \\[(.+?)\\] that is not passed","errorType":"exception","errorClass":"QueryException","httpStatus":null,"severity":"error","filePath":"hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/function/json/SingleStoreJsonArrayAppendFunction.java","lineNumber":81,"sourceCode":"\n\tprivate static boolean isNumeric(SqlAstNode value) {\n\t\treturn value instanceof UnparsedNumericLiteral<?>;\n\t}\n\n\tprivate static void buildJsonArrayPushValue(SqlAppender sqlAppender, SqlAstNode value) {\n\t\tsqlAppender.appendSql( \"json_array_push_\" );\n\t\tsqlAppender.appendSql( isNumeric( value ) ? \"double(\" : \"string(\" );\n\t}\n\n\tprivate static void buildJsonPath(\n\t\t\tSqlAppender sqlAppender, Expression jsonPath, List<JsonPathHelper.JsonPathElement> jsonPathElements) {\n\t\tfor ( JsonPathHelper.JsonPathElement pathElement : jsonPathElements ) {\n\t\t\tsqlAppender.appendSql( ',' );\n\t\t\tif ( pathElement instanceof JsonPathHelper.JsonAttribute attribute ) {\n\t\t\t\tsqlAppender.appendSingleQuoteEscapedString( attribute.attribute() );\n\t\t\t}\n\t\t\telse if ( pathElement instanceof JsonPathHelper.JsonParameterIndexAccess indexParameter) {\n\t\t\t\tthrow new QueryException( \"JSON path [\" + jsonPath + \"] uses parameter [\" + indexParameter.parameterName() + \"] that is not passed\" );\n\t\t\t}\n\t\t\telse {\n\t\t\t\tsqlAppender.appendSql( '\\'' );\n\t\t\t\tsqlAppender.appendSql( ( (JsonPathHelper.JsonIndexAccess) pathElement ).index() );\n\t\t\t\tsqlAppender.appendSql( '\\'' );\n\t\t\t}\n\t\t}\n\t}\n}\n","sourceCodeStart":63,"sourceCodeEnd":91,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/function/json/SingleStoreJsonArrayAppendFunction.java#L63-L91","documentation":"Hibernate's JSON path syntax allows parameter markers inside brackets (e.g. 'items[$i]') that must be supplied through a PASSING clause. The SingleStore json_array_append emulation has no passing support and renders each path element as a constant, so buildJsonPath throws QueryException the moment it encounters a JsonParameterIndexAccess element whose parameter was not passed.","triggerScenarios":"HQL `json_array_append(e.doc, 'items[$i]', :v)` (any path literal containing a [$name] segment) on SingleStoreDialect, with or without a passing clause.","commonSituations":"Dynamic array indexing code shared with PostgreSQL-style dialects that honor passing; generated queries that parameterize positions inside JSON paths.","solutions":["Inline the concrete index into the path string in Java (e.g. 'items[3]') before binding","Render the whole path as a literal per index and execute one statement per position","Keep json_array_append calls on SingleStore limited to fully literal paths","Use a native SingleStore statement for dynamic paths"],"exampleFix":"// before (path contains parameter marker $i)\njson_array_append(e.doc, 'items[$i]', :v)\n\n// after: build literal path in Java\nString path = \"items[\" + index + \"]\";\nem.createQuery(\"update E e set e.doc = json_array_append(e.doc, '\" + path + \"', :v)\")\n    .setParameter(\"v\", v).executeUpdate();","handlingStrategy":"validation","validationCode":"// Reject $-parameter markers in JSON paths before executing on SingleStore\nprivate static final Pattern PARAM_IN_PATH = Pattern.compile(\"\\\\[\\\\s*\\\\$\\\\w+\");\nstatic String requireLiteralPath(String path) {\n    if (PARAM_IN_PATH.matcher(path).find()) {\n        throw new IllegalArgumentException(\"Inline the index instead of [$param]: \" + path);\n    }\n    return path;\n}","typeGuard":null,"tryCatchPattern":"try {\n    em.createQuery(hql).executeUpdate(); // json_array_append with [$i] path\n} catch (QueryException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"that is not passed\")) {\n        // rebuild the path with a concrete index and retry\n    }\n    throw e;\n}","preventionTips":["On SingleStore, always build JSON paths with concrete indices in Java","Never copy PostgreSQL-style passing-clause paths to SingleStore queries","Validate path strings against a [$...] pattern in a shared utility"],"tags":["hibernate","singlestore","json-array-append","json-path","parameters"],"backgroundTag":"json-path-parameter-not-passed","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}