{"record":{"id":"73b87809ddc4731f","repo":"hibernate/hibernate-orm","slug":"json-path-jsonpath-uses-parameter-p-73b878","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/SingleStoreJsonRemoveFunction.java","lineNumber":47,"sourceCode":"\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 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\tsqlAppender.appendSql( \"json_delete_key(\" );\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}\n}\n","sourceCodeStart":29,"sourceCodeEnd":58,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/function/json/SingleStoreJsonRemoveFunction.java#L29-L58","documentation":"The JSON path argument of the HQL json_remove() function (emulated as json_delete_key(json, 'attr', ...) on SingleStore) contains a '$name' variable reference from the PASSING clause. Since the dialect must expand each path element into a literal argument, a JsonParameterIndexAccess element cannot be rendered and a QueryException is thrown naming the parameter.","triggerScenarios":"HQL update/delete form like: set e.doc = json_remove(e.doc, '$.arr[$i]' passing e.idx as i) - i.e. any json_remove call whose path contains $param index access on SingleStore.","commonSituations":"Removing array elements by runtime index in JSON documents; porting Oracle/PostgreSQL JSON manipulation code to SingleStore; dynamic attribute pruning of JSON payloads.","solutions":["Use a literal index in the path: json_remove(e.doc, '$.arr[2]').","Construct the literal path string in Java with the index validated as an integer and interpolated.","Read the document, apply the removal in Java (e.g. with Jackson/Jackson-databind), and write it back.","Fall back to a native UPDATE using SingleStore json_delete_key with a literal key list."],"exampleFix":"// before - throws: $i cannot be rendered\nupdate Event e set e.doc = json_remove(e.doc, '$.tags[$i]' passing e.idx as i)\n\n// after - literal index\nupdate Event e set e.doc = json_remove(e.doc, '$.tags[1]')","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_remove(e.doc, '\" + path + \"')\";","typeGuard":null,"tryCatchPattern":"try {\n    session.createMutationQuery(hql).executeUpdate();\n} catch (QueryException e) {\n    if (e.getMessage().contains(\"that is not passed\")) {\n        mutateDocInJavaAndMerge(session); // parse, remove key, persist\n        return;\n    }\n    throw e;\n}","preventionTips":["Use literal attribute/index paths in json_remove on SingleStore","Perform structural JSON edits in Java when indices are dynamic"],"tags":["singlestore","json","json-remove","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"}