{"record":{"id":"c1ab7f33c6ba8c9b","repo":"hibernate/hibernate-orm","slug":"can-t-pass-parameter-because-json-table-has","errorCode":null,"errorMessage":"Can't pass parameter '{}', because json_table has no JSON path","messagePattern":"Can't pass parameter '(.+?)', because json_table has no JSON path","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/sqm/tree/spi/expression/SqmJsonTableFunction.java","lineNumber":130,"sourceCode":"\tprivate static List<SqmTypedNode<?>> createArgumentsList(SqmExpression<?> document, @Nullable SqmExpression<String> jsonPath) {\n\t\t// Since the last argument is the Columns object, though that needs the `this` reference,\n\t\t// we need to construct an array with a null slot at the end, where the Columns instance is put into.\n\t\t// Suppress nullness checks as this will eventually turn non-nullable\n\t\t@SuppressWarnings(\"NullAway\")\n\t\tfinal SqmTypedNode<?>[] array = jsonPath == null\n\t\t\t\t? new SqmTypedNode[] {document, null}\n\t\t\t\t: new SqmTypedNode[] {document, jsonPath, null};\n\t\treturn Arrays.asList( array );\n\t}\n\n\tpublic Map<String, SqmExpression<?>> getPassingExpressions() {\n\t\treturn passingExpressions == null ? Collections.emptyMap() : Collections.unmodifiableMap( passingExpressions );\n\t}\n\n\t@Override\n\tpublic JpaJsonTableFunction passing(String parameterName, Expression<?> expression) {\n\t\tif ( columns.jsonPath == null ) {\n\t\t\tthrow new IllegalStateException( \"Can't pass parameter '\" + parameterName + \"', because json_table has no JSON path\" );\n\t\t}\n\t\tif ( passingExpressions == null ) {\n\t\t\tpassingExpressions = new HashMap<>();\n\t\t}\n\t\tpassingExpressions.put( parameterName, (SqmExpression<?>) expression );\n\t\treturn this;\n\t}\n\n\t@Override\n\tpublic SqmJsonTableFunction<T> copy(SqmCopyContext context) {\n\t\tfinal var existing = context.getCopy( this );\n\t\tif ( existing != null ) {\n\t\t\treturn existing;\n\t\t}\n\t\tfinal List<? extends SqmTypedNode<?>> arguments = getArguments();\n\t\tfinal List<SqmTypedNode<?>> argumentsCopy = new ArrayList<>( arguments.size() );\n\t\tfor ( int i = 0; i < arguments.size() - 1; i++ ) {\n\t\t\targumentsCopy.add( arguments.get( i ).copy( context ) );","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/spi/expression/SqmJsonTableFunction.java#L112-L148","documentation":"In SQL/JSON, json_table's PASSING clause supplies values that placeholders inside the JSON path expression reference. SqmJsonTableFunction only tracks passing expressions when it was created with a JSON path (getArguments() lays out [document, jsonPath, null] versus [document, null]); calling passing() when columns.jsonPath is null is a modeling error, so it throws IllegalStateException.","triggerScenarios":"Calling .passing(parameterName, expression) on a json_table criteria function that was built without the JSON path argument - e.g. using the pathless creation variant and then trying to parameterize the (nonexistent) path expression.","commonSituations":"Query-builder wrappers that optionally omit the path; refactors that dropped the path argument; xml_table-style code reused for json_table; adapting examples that always used a path to a pathless use case.","solutions":["Create the json_table function with its JSON path first, then call passing().","If the query genuinely needs no path, remove the passing() call - there is nothing for the parameter to bind to.","Centralize json_table construction so a pathless instance is never handed to code that calls passing()."],"exampleFix":"// before\nJpaJsonTableFunction<?> t = cb.jsonTable( doc );  // no JSON path\nt.passing( \"minLen\", cb.literal( 3 ) );           // IllegalStateException\n\n// after\nJpaJsonTableFunction<?> t = cb.jsonTable( doc, \"$.items[*]?(@.len > $minLen)\" );\nt.passing( \"minLen\", cb.literal( 3 ) );","handlingStrategy":"validation","validationCode":"Objects.requireNonNull( jsonPath, \"json_table requires a JSON path when passing() is used\" );\nJpaJsonTableFunction<?> t = cb.jsonTable( doc, jsonPath );\nif ( passingValue != null ) {\n    t.passing( \"name\", passingValue );\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never call passing() on a json_table built without a JSON path.","Encapsulate json_table construction so the path is a required parameter whenever PASSING values are used.","Add a builder-level assertion that ties passing() to the presence of a path."],"tags":["hibernate","json-table","criteria-api","sql-json","passing-clause"],"backgroundTag":"invalid-function-arguments","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}