hibernate/hibernate-orm · error · QueryException

JSON path [" + jsonPath + "] uses parameter [" + parameterNa

Error message

JSON path [" + jsonPath + "] uses parameter [" + parameterName + "] that is not passed

What it means

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.

Source

Thrown at hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/function/json/SingleStoreJsonRemoveFunction.java:47

	public void render(
			SqlAppender sqlAppender,
			List<? extends SqlAstNode> arguments,
			ReturnableType<?> returnType,
			SqlAstTranslator<?> translator) {
		final Expression json = (Expression) arguments.get( 0 );
		final Expression jsonPath = (Expression) arguments.get( 1 );
		final List<JsonPathHelper.JsonPathElement> jsonPathElements = JsonPathHelper.parseJsonPathElements( translator.getLiteralValue(
				jsonPath ) );
		sqlAppender.appendSql( "json_delete_key(" );
		json.accept( translator );
		for ( JsonPathHelper.JsonPathElement pathElement : jsonPathElements ) {
			sqlAppender.appendSql( ',' );
			if ( pathElement instanceof JsonPathHelper.JsonAttribute attribute ) {
				sqlAppender.appendSingleQuoteEscapedString( attribute.attribute() );
			}
			else if ( pathElement instanceof JsonPathHelper.JsonParameterIndexAccess indexParameter) {
				final String parameterName = indexParameter.parameterName();
				throw new QueryException( "JSON path [" + jsonPath + "] uses parameter [" + parameterName + "] that is not passed" );
			}
			else {
				sqlAppender.appendSql( '\'' );
				sqlAppender.appendSql( ( (JsonPathHelper.JsonIndexAccess) pathElement ).index() );
				sqlAppender.appendSql( '\'' );
			}
		}
		sqlAppender.appendSql( ')' );
	}
}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Use a literal index in the path: json_remove(e.doc, '$.arr[2]').
  2. Construct the literal path string in Java with the index validated as an integer and interpolated.
  3. Read the document, apply the removal in Java (e.g. with Jackson/Jackson-databind), and write it back.
  4. Fall back to a native UPDATE using SingleStore json_delete_key with a literal key list.

Example fix

// before - throws: $i cannot be rendered
update Event e set e.doc = json_remove(e.doc, '$.tags[$i]' passing e.idx as i)

// after - literal index
update Event e set e.doc = json_remove(e.doc, '$.tags[1]')
Defensive patterns

Strategy: fallback

Validate before calling

if (path.indexOf('$', 1) >= 0) throw new IllegalArgumentException("$param path unsupported on SingleStore: " + path);
String hql = "update Event e set e.doc = json_remove(e.doc, '" + path + "')";

Try / catch

try {
    session.createMutationQuery(hql).executeUpdate();
} catch (QueryException e) {
    if (e.getMessage().contains("that is not passed")) {
        mutateDocInJavaAndMerge(session); // parse, remove key, persist
        return;
    }
    throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: Removing array elements by runtime index in JSON documents; porting Oracle/PostgreSQL JSON manipulation code to SingleStore; dynamic attribute pruning of JSON payloads.

Related errors


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/73b87809ddc4731f. Report an issue: GitHub.