{"record":{"id":"819029dff0ebc42f","repo":"hibernate/hibernate-orm","slug":"json-path-uses-parameter-that-is-not-pas-819029","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/SingleStoreJsonExistsFunction.java","lineNumber":53,"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_exists 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_match_any_exists(\" );\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 jsonParameterIndexAccess) {\n\t\t\t\tfinal String parameterName = jsonParameterIndexAccess.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":35,"sourceCodeEnd":64,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/function/json/SingleStoreJsonExistsFunction.java#L35-L64","documentation":"After parsing the (literal) JSON path for json_exists, SingleStore's render loop emits each element as a constant attribute or quoted index. A [$name] parameter marker inside the path cannot be resolved because the emulation supports no passing clause, so it throws QueryException naming the path and the unpassed parameter.","triggerScenarios":"HQL `json_exists(e.doc, 'items[$i]')` — any literal path containing a bracketed $name marker — on SingleStoreDialect.","commonSituations":"Dynamic existence checks written for dialects with passing support; parameterized JSON traversal shared across backends.","solutions":["Inline the concrete index into the path literal in Java","Keep json_exists paths on SingleStore fully constant","Execute one literal-path query per position","Use a native SingleStore statement for dynamic paths"],"exampleFix":"// before\njson_exists(e.doc, 'items[$i]')\n\n// after\nString path = \"items[\" + index + \"]\";\nem.createQuery(\"select e from E e where json_exists(e.doc, '\" + path + \"')\");","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    return em.createQuery(hql).getResultList(); // json_exists with [$i] in path\n} catch (QueryException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"that is not passed\")) {\n        // inline the concrete index into the path literal and retry\n    }\n    throw e;\n}","preventionTips":["Never include [$name] markers in SingleStore JSON paths","Build existence-check paths in Java with concrete indices","Run the shared path validator in every JSON query builder entry point"],"tags":["hibernate","singlestore","json-exists","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"}