hibernate/hibernate-orm · error · QueryException

JSON path [{}] uses parameter [{}] that is not passed

Error message

JSON path [{}] uses parameter [{}] that is not passed

What it means

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.

Source

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

		}
		final String jsonPath;
		try {
			jsonPath = walker.getLiteralValue( arguments.jsonPath() );
		}
		catch (Exception ex) {
			throw new QueryException( "SingleStore json_exists only support literal json paths, but got " + arguments.jsonPath() );
		}
		final List<JsonPathHelper.JsonPathElement> jsonPathElements = JsonPathHelper.parseJsonPathElements( jsonPath );
		sqlAppender.appendSql( "json_match_any_exists(" );
		arguments.jsonDocument().accept( walker );
		for ( JsonPathHelper.JsonPathElement pathElement : jsonPathElements ) {
			sqlAppender.appendSql( ',' );
			if ( pathElement instanceof JsonPathHelper.JsonAttribute attribute ) {
				sqlAppender.appendSingleQuoteEscapedString( attribute.attribute() );
			}
			else if ( pathElement instanceof JsonPathHelper.JsonParameterIndexAccess jsonParameterIndexAccess) {
				final String parameterName = jsonParameterIndexAccess.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. Inline the concrete index into the path literal in Java
  2. Keep json_exists paths on SingleStore fully constant
  3. Execute one literal-path query per position
  4. Use a native SingleStore statement for dynamic paths

Example fix

// before
json_exists(e.doc, 'items[$i]')

// after
String path = "items[" + index + "]";
em.createQuery("select e from E e where json_exists(e.doc, '" + path + "')");
Defensive patterns

Strategy: validation

Validate before calling

private static final Pattern PARAM_IN_PATH = Pattern.compile("\\[\\s*\\$\\w+");
static String requireLiteralPath(String path) {
    if (PARAM_IN_PATH.matcher(path).find()) {
        throw new IllegalArgumentException("Inline the index instead of [$param]: " + path);
    }
    return path;
}

Try / catch

try {
    return em.createQuery(hql).getResultList(); // json_exists with [$i] in path
} catch (QueryException e) {
    if (e.getMessage() != null && e.getMessage().contains("that is not passed")) {
        // inline the concrete index into the path literal and retry
    }
    throw e;
}

Prevention

When it happens

Trigger: HQL `json_exists(e.doc, 'items[$i]')` — any literal path containing a bracketed $name marker — on SingleStoreDialect.

Common situations: Dynamic existence checks written for dialects with passing support; parameterized JSON traversal shared across backends.

Related errors


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