quarkusio/quarkus · error · IllegalArgumentException

Attribute ${attr} of @Query is currently not supported. Offe

Error message

Attribute ${attr} of @Query is currently not supported. Offending method is ${method} of Repository ${repository}

What it means

The extension only supports the 'value' (and 'countName'/'countQuery'-style value field) attributes of Spring Data's @Query annotation at build time. Any other attribute set on @Query (e.g. nativeQuery, name, countName in unsupported form) is rejected with this IllegalArgumentException during augmentation because generating the query method cannot honor it.

Source

Thrown at extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/generate/CustomQueryMethodsAdder.java:425

            customClassCreatedCallback.accept(implName.toString());
        }
    }

    private Set<String> extractNamedParameters(String queryString) {
        Set<String> namedParameters = new LinkedHashSet<>();
        final Matcher matcher = NAMED_PARAMETER.matcher(queryString);
        while (matcher.find()) {
            namedParameters.add(matcher.group(1));
        }
        return namedParameters;
    }

    // we currently only support the 'value' attribute of @Query
    private void verifyQueryAnnotation(AnnotationInstance queryInstance, String methodName, String repositoryName) {
        List<AnnotationValue> values = queryInstance.values();
        for (AnnotationValue value : values) {
            if (!QUERY_VALUE_FIELD.equals(value.name()) && !QUERY_COUNT_FIELD.equals(value.name())) {
                throw new IllegalArgumentException("Attribute " + value.name() + " of @Query is currently not supported. " +
                        "Offending method is " + methodName + " of Repository " + repositoryName);
            }
        }
        if (queryInstance.value(QUERY_VALUE_FIELD) == null) {
            throw new IllegalArgumentException("'value' attribute must be specified on @Query annotation of method. " +
                    "Offending method is " + methodName + " of Repository " + repositoryName);
        }
    }

    private Expr generateParamsArray(List<Integer> queryParameterIndexes, BlockCreator bc, ParamVar[] params) {
        LocalVar paramsArray = bc.localVar("paramsArray", bc.newEmptyArray(Object.class, queryParameterIndexes.size()));
        for (int i = 0; i < queryParameterIndexes.size(); i++) {
            bc.set(paramsArray.elem(i), params[queryParameterIndexes.get(i)]);
        }
        return paramsArray;
    }

    private Expr generateParametersObject(Map<String, Integer> namedParameterToIndex, BlockCreator bc, ParamVar[] params) {

View on GitHub (pinned to e1c734241f)

Solutions

  1. Remove unsupported attributes from @Query, keeping only value
  2. For native SQL, replace the native query with an equivalent JPQL query
  3. Perform the native query outside the repository via EntityManager in a custom repository fragment
  4. Check the extension version/docs for the currently supported @Query attribute set

Example fix

// before
@Query(value = "SELECT * FROM users WHERE age > :age", nativeQuery = true)
List<User> findOlderThan(int age);

// after
@Query("SELECT u FROM User u WHERE u.age > :age")
List<User> findOlderThan(int age);
Defensive patterns

Strategy: validation

Validate before calling

// keep only 'value' (and supported count attribute) on @Query
Set<String> allowed = Set.of("value", "countQuery");

Prevention

When it happens

Trigger: Using @Query with an attribute other than 'value' (the QUERY_VALUE_FIELD) or the supported count field, e.g. @Query(value = "...", nativeQuery = true), verified in CustomQueryMethodsAdder.verifyQueryAnnotation.

Common situations: Migrating Spring Data repositories that use nativeQuery = true; copying @Query definitions with named-query attributes (name/countName) from Spring projects.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/f336a0221b14baf3. Report an issue: GitHub.