{"record":{"id":"22d5e00361597304","repo":"hibernate/hibernate-orm","slug":"json-path-jsonpath-uses-parameter-p-22d5e0","errorCode":null,"errorMessage":"JSON path [\" + jsonPath + \"] uses parameter [\" + parameterName + \"] that is not passed","messagePattern":"JSON path \\[\" \\+ jsonPath \\+ \"\\] uses parameter \\[\" \\+ parameterName \\+ \"\\] 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/SingleStoreJsonValueFunction.java","lineNumber":66,"sourceCode":"\t\t}\n\t\tfinal String jsonPath;\n\t\ttry {\n\t\t\tjsonPath = walker.getLiteralValue( arguments.jsonPath() );\n\t\t}\n\t\tcatch (Exception ex) {\n\t\t\tthrow new QueryException( \"SingleStore json_value only support literal json paths, but got \" + arguments.jsonPath() );\n\t\t}\n\t\tfinal List<JsonPathHelper.JsonPathElement> jsonPathElements = JsonPathHelper.parseJsonPathElements( jsonPath );\n\t\tsqlAppender.appendSql( \"json_extract_string(\" );\n\t\targuments.jsonDocument().accept( walker );\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\tfinal String parameterName = indexParameter.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\tsqlAppender.appendSql( ')' );\n\t\tif ( arguments.returningType() != null ) {\n\t\t\tif ( arguments.returningType().getJdbcMapping().getJdbcType().isBoolean() ) {\n\t\t\t\tsqlAppender.append( \" when 'true' then true when 'false' then false end \" );\n\t\t\t}\n\t\t\telse {\n\t\t\t\tsqlAppender.appendSql( \" as \" );\n\t\t\t\targuments.returningType().accept( walker );\n\t\t\t\tsqlAppender.appendSql( ')' );\n\t\t\t}\n\t\t}","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/function/json/SingleStoreJsonValueFunction.java#L48-L84","documentation":"The literal JSON path passed to json_value() contains a '$name' variable reference (from HQL's PASSING clause, e.g. '$.items[$idx]' passing idx). While expanding path elements into json_extract_string arguments, the SingleStore dialect hits a JsonParameterIndexAccess element and throws this QueryException, because passed parameters cannot be injected into the generated SQL.","triggerScenarios":"HQL like: select json_value(e.doc, '$.arr[$i]' passing e.idx as i) from Event e - any $param index reference inside the jsonpath of a json_value call on SingleStore.","commonSituations":"Runtime-selected array element extraction; queries shared across databases that rely on the PASSING clause; porting Oracle-style parametrized paths to SingleStore.","solutions":["Replace the $param reference with a literal index: '$.arr[0]'.","Interpolate the index into a literal path built in Java (validate it is an integer).","Extract the array with json_query and index it in Java.","Fall back to native SQL with json_extract and a bound index."],"exampleFix":"// before - throws: $i is a path parameter\nselect json_value(e.doc, '$.items[$i]' passing e.idx as i) from Event e\n\n// after - literal index\nselect json_value(e.doc, '$.items[2]') from Event e","handlingStrategy":"fallback","validationCode":"if (path.indexOf('$', 1) >= 0) throw new IllegalArgumentException(\"$param path unsupported on SingleStore: \" + path);\nString literalPath = \"$.items[\" + requireInt(index) + \"]\";","typeGuard":null,"tryCatchPattern":"try {\n    return session.createQuery(hql, String.class).getSingleResult();\n} catch (QueryException e) {\n    if (e.getMessage().contains(\"that is not passed\")) {\n        return extractInJava(session); // fetch array, index in Java\n    }\n    throw e;\n}","preventionTips":["Do not use the PASSING clause with json_value on SingleStore","Interpolate validated integer indices as literal path segments"],"tags":["singlestore","json","json-value","json-path","hql","passing-clause"],"backgroundTag":"unsupported-bind-parameter","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}