quarkusio/quarkus · error · IllegalArgumentException
of Repository is meant to be a insert/update/delete query…
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.
Solutions
- Remove the Pageable/PageRequest and Sort parameters from the modifying method
- Restrict the affected rows in the WHERE clause instead of using pagination (e.g. by date range or id list)
- If paginated deletion is truly required, select the ids with a paginated read method and then delete with an IN clause
- 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
- Never add Pageable/Sort to @Modifying methods
- Restrict bulk statements with WHERE clauses instead of pagination
- Select ids first, then delete/update with IN
- Double-check @Modifying is intended for the method
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
- Method of Repository has invalid parameters - only a single…
- Attribute of @Query is currently not supported. Offending…
- Currently only Entities with the @Id or @EmbeddedId…
- Currently the @Id or @EmbeddedId annotation can only be…
- Currently the @Version annotation can only be placed on a…
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/1890eece8d4eed88.
Report an issue: GitHub.
Appendix: 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)