quarkusio/quarkus · error · IllegalArgumentException

${method.name()} of Repository ${repositoryClassInfo} is mea

Error message

${method.name()} of Repository ${repositoryClassInfo} is meant to be a insert/update/delete query and therefore doesn't support Pageable and Sort method parameters

What it means

Methods annotated with @Modifying (insert/update/delete queries) cannot use Pageable or Sort parameters, since pagination and ordering are meaningless for bulk modification statements. Quarkus enforces this at build time with this IllegalArgumentException.

Source

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

                var index = (int) annotation.target().asMethodParameter().position();
                namedParameterToIndex.put(annotation.value().asString(), index);
            }
            // if no or only some parameters are annotated with @Param, add the compiled names (if present)
            if (namedParameterToIndex.size() < methodParameterTypes.size()) {
                for (int index = 0; index < methodParameterTypes.size(); index++) {
                    if (namedParameterToIndex.containsValue(index)) {
                        continue;
                    }
                    String parameterName = method.parameterName(index);
                    if (parameterName != null) {
                        namedParameterToIndex.put(parameterName, index);
                    }
                }
            }

            boolean isModifying = (method.annotation(DotNames.SPRING_DATA_MODIFYING) != null);
            if (isModifying && (sortParameterIndex != null || pageableParameterIndex != null)) {
                throw new IllegalArgumentException(
                        method.name() + " of Repository " + repositoryClassInfo
                                + " is meant to be a insert/update/delete query and therefore doesn't " +
                                "support Pageable and Sort method parameters");
            }

            Set<String> usedNamedParameters = extractNamedParameters(queryString);
            if (!usedNamedParameters.isEmpty()) {
                Set<String> missingParameters = new LinkedHashSet<>(usedNamedParameters);
                missingParameters.removeAll(namedParameterToIndex.keySet());
                if (!missingParameters.isEmpty()) {
                    throw new IllegalArgumentException(
                            method.name() + " of Repository " + repositoryClassInfo
                                    + " is missing the named parameters " + missingParameters
                                    + ", provided are " + namedParameterToIndex.keySet()
                                    + ". Ensure that the parameters are correctly annotated with @Param.");
                }
                namedParameterToIndex.keySet().retainAll(usedNamedParameters);
            } else {

View on GitHub (pinned to e1c734241f)

Solutions

  1. Remove the Pageable/PageRequest and Sort parameters from the modifying method
  2. Restrict the affected rows in the WHERE clause instead of using pagination (e.g. by date range or id list)
  3. If paginated deletion is truly required, select the ids with a paginated read method and then delete with an IN clause
  4. Verify @Modifying is actually intended — if the query is a select, drop the annotation and keep Pageable

Example fix

// before
@Modifying
@Query("delete from User u where u.inactive = true")
void deleteInactive(Pageable page);
// after
@Modifying
@Query("delete from User u where u.inactive = true")
void deleteInactive();
Defensive patterns

Strategy: validation

Validate before calling

if (method.isAnnotationPresent(Modifying.class)) {
    boolean hasPaging = Arrays.stream(method.getParameterTypes())
        .anyMatch(t -> Pageable.class.isAssignableFrom(t) || Sort.class.equals(t));
    if (hasPaging) throw new IllegalArgumentException("@Modifying methods cannot take Pageable/Sort");
}

Try / catch

try {
    compile();
} catch (IllegalArgumentException e) {
    if (e.getMessage().contains("doesn't support Pageable and Sort")) {
        log.error("Strip Pageable/Sort from the modifying method");
    }
    throw e;
}

Prevention

When it happens

Trigger: A repository method annotated with @Query and @Modifying whose signature includes a Pageable/PageRequest or Sort parameter, e.g. @Modifying @Query("delete from User u where u.lastLogin < :d") void deleteInactive(Pageable p).

Common situations: Copy-pasting a read method signature (which legitimately takes Pageable) into a bulk delete/update method; intending to batch deletes with pagination — which JPQL bulk statements do not support; misuse of @Modifying on what is actually a select query.

Related errors


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