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_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.

Source

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

			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 ) );
		final SqlAstNode value = arguments.get( 2 );
		sqlAppender.appendSql( "json_set_" );
		sqlAppender.appendSql( isNumeric( value ) ? "double(" : "string(" );
		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( ',' );
		value.accept( translator );
		sqlAppender.appendSql( ')' );
	}

	private static boolean isNumeric(SqlAstNode value) {
		return value instanceof UnparsedNumericLiteral<?>;
	}

}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Use a literal index in the path: json_set(e.doc, '$.arr[2]', e.val).
  2. Build the literal path in Java with the index validated and interpolated before creating the query.
  3. Mutate the JSON document in Java (parse, set, serialize) and persist the result.
  4. Fall back to native SQL with json_set_double/json_set_string and literal keys.

Example fix

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

// after - literal index
update Event e set e.doc = json_set(e.doc, '$.items[1]', e.v)
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_set(e.doc, '" + path + "', :value)";

Try / catch

try {
    session.createMutationQuery(hql).setParameter("value", v).executeUpdate();
} catch (QueryException e) {
    if (e.getMessage().contains("that is not passed")) {
        setInJavaAndMerge(session); // parse doc, set value, persist
        return;
    }
    throw e;
}

Prevention

When it happens

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

Common situations: 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.

Related errors


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