{"record":{"id":"2fbb91eaf874d13c","repo":"hibernate/hibernate-orm","slug":"json-path-uses-parameter-that-is-not-pas-2fbb91","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/SingleStoreJsonArrayInsertFunction.java","lineNumber":105,"sourceCode":"\t\treturn value instanceof UnparsedNumericLiteral<?>;\n\t}\n\n\tprivate static void buildJsonArrayInsertValue(SqlAppender sqlAppender, SqlAstNode value) {\n\t\tsqlAppender.appendSql( \"json_splice_\" );\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 ( int i = 0; i < jsonPathElements.size() - 1; i++ ) {\n\t\t\tJsonPathHelper.JsonPathElement pathElement = jsonPathElements.get( i );\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 jsonPathElement) {\n\t\t\t\tfinal String parameterName = jsonPathElement.parameterName();\n\t\t\t\tthrow new QueryException( \"JSON path [\" + jsonPath + \"] uses parameter [\" + 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":87,"sourceCodeEnd":115,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/function/json/SingleStoreJsonArrayInsertFunction.java#L87-L115","documentation":"Like the other SingleStore JSON emulations, json_array_insert renders every path element as a constant attribute or index. buildJsonPath walks the leading path elements and throws QueryException when it finds a [$name] parameter marker (JsonParameterIndexAccess) whose parameter was not passed, because SingleStore has no passing support.","triggerScenarios":"HQL `json_array_insert(e.doc, 'items[$i][0]', :v)` — any parameter marker in the non-final path segments — on SingleStoreDialect.","commonSituations":"Dynamic array navigation shared across dialects; queries copied from PostgreSQL-flavored HQL that rely on a passing clause.","solutions":["Inline the concrete index into the path literal in Java before creating the query","Restrict json_array_insert on SingleStore to fully literal paths","Execute one statement per concrete position instead of parameterizing inside the path","Fall back to a native SingleStore statement for dynamic paths"],"exampleFix":"// before\njson_array_insert(e.doc, 'items[$i][0]', :v)\n\n// after: build the literal path in Java\nString path = \"items[\" + index + \"][0]\";\nem.createQuery(\"update E e set e.doc = json_array_insert(e.doc, '\" + path + \"', :v)\")\n    .setParameter(\"v\", v).executeUpdate();","handlingStrategy":"validation","validationCode":"private 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_insert with [$i] path\n} catch (QueryException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"that is not passed\")) {\n        // inline concrete indices into the path literal and retry\n    }\n    throw e;\n}","preventionTips":["Keep json_array_insert paths fully literal on SingleStore","Generate one statement per concrete index rather than parameterizing positions","Share the [$param] path validator across all SingleStore JSON functions"],"tags":["hibernate","singlestore","json-array-insert","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"}