{"record":{"id":"5ccec81839538032","repo":"hibernate/hibernate-orm","slug":"json-path-jsonpath-uses-parameter-p-5ccec8","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/SingleStoreJsonSetFunction.java","lineNumber":52,"sourceCode":"\t\t\tList<? extends SqlAstNode> arguments,\n\t\t\tReturnableType<?> returnType,\n\t\t\tSqlAstTranslator<?> translator) {\n\t\tfinal Expression json = (Expression) arguments.get( 0 );\n\t\tfinal Expression jsonPath = (Expression) arguments.get( 1 );\n\t\tfinal List<JsonPathHelper.JsonPathElement> jsonPathElements = JsonPathHelper.parseJsonPathElements( translator.getLiteralValue(\n\t\t\t\tjsonPath ) );\n\t\tfinal SqlAstNode value = arguments.get( 2 );\n\t\tsqlAppender.appendSql( \"json_set_\" );\n\t\tsqlAppender.appendSql( isNumeric( value ) ? \"double(\" : \"string(\" );\n\t\tjson.accept( translator );\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\tvalue.accept( translator );\n\t\tsqlAppender.appendSql( ')' );\n\t}\n\n\tprivate static boolean isNumeric(SqlAstNode value) {\n\t\treturn value instanceof UnparsedNumericLiteral<?>;\n\t}\n\n}\n","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/function/json/SingleStoreJsonSetFunction.java#L34-L70","documentation":"The JSON path argument of the HQL json_set() function (emulated as json_set_double(...)/json_set_string(...) on SingleStore) contains a '$name' variable reference from the PASSING clause. The dialect expands path elements into literal SQL arguments; a JsonParameterIndexAccess element has no literal form, so rendering aborts with this QueryException.","triggerScenarios":"HQL like: update Event e set e.doc = json_set(e.doc, '$.arr[$i]', e.val passing e.idx as i) - any json_set call whose path contains $param index access on SingleStore.","commonSituations":"Writing values into JSON arrays at a runtime-computed index; porting JSON update statements from Oracle/PostgreSQL to SingleStore; multi-tenant schemas that address fields via variables.","solutions":["Use a literal index in the path: json_set(e.doc, '$.arr[2]', e.val).","Build the literal path in Java with the index validated and interpolated before creating the query.","Mutate the JSON document in Java (parse, set, serialize) and persist the result.","Fall back to native SQL with json_set_double/json_set_string and literal keys."],"exampleFix":"// before - throws: $i cannot be rendered\nupdate Event e set e.doc = json_set(e.doc, '$.items[$i]', e.v passing e.idx as i)\n\n// after - literal index\nupdate Event e set e.doc = json_set(e.doc, '$.items[1]', e.v)","handlingStrategy":"fallback","validationCode":"if (path.indexOf('$', 1) >= 0) throw new IllegalArgumentException(\"$param path unsupported on SingleStore: \" + path);\nString hql = \"update Event e set e.doc = json_set(e.doc, '\" + path + \"', :value)\";","typeGuard":null,"tryCatchPattern":"try {\n    session.createMutationQuery(hql).setParameter(\"value\", v).executeUpdate();\n} catch (QueryException e) {\n    if (e.getMessage().contains(\"that is not passed\")) {\n        setInJavaAndMerge(session); // parse doc, set value, persist\n        return;\n    }\n    throw e;\n}","preventionTips":["Use literal paths in json_set on SingleStore","Mutate JSON documents in Java when the target index is computed at runtime"],"tags":["singlestore","json","json-set","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"}