quarkusio/quarkus · error · IllegalArgumentException
Method ${method} of Repository ${repository}has invalid para
Error message
Method ${method} of Repository ${repository}has invalid parameters - only a single parameter of type Sort can be specified What it means
A derived repository method may take at most one Sort parameter. DerivedMethodsAdder.add throws this error at build time when two or more parameters of type org.springframework.data.domain.Sort appear in the method signature, since sorting can only be applied once per generated query.
Source
Thrown at extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/generate/DerivedMethodsAdder.java:122
List<Integer> queryParameterIndexes = new ArrayList<>(parameters.size());
Integer pageableParameterIndex = null;
Integer sortParameterIndex = null;
Integer dynamicProjectionParameterIndex = null;
for (int i = 0; i < parameters.size(); i++) {
Type paramType = parameters.get(i);
DotName parameterType = paramType.name();
parameterTypesStr[i] = parameterType.toString();
if (DotNames.SPRING_DATA_PAGEABLE.equals(parameterType)
|| DotNames.SPRING_DATA_PAGE_REQUEST.equals(parameterType)) {
if (pageableParameterIndex != null) {
throw new IllegalArgumentException("Method " + method.name() + " of Repository " + repositoryClassInfo
+ "has invalid parameters - only a single parameter of type" + DotNames.SPRING_DATA_PAGEABLE
+ " can be specified");
}
pageableParameterIndex = i;
} else if (DotNames.SPRING_DATA_SORT.equals(parameterType)) {
if (sortParameterIndex != null) {
throw new IllegalArgumentException("Method " + method.name() + " of Repository " + repositoryClassInfo
+ "has invalid parameters - only a single parameter of type" + DotNames.SPRING_DATA_SORT
+ " can be specified");
}
sortParameterIndex = i;
} else if (isDynamicProjectionParameter(paramType, method)) {
if (dynamicProjectionParameterIndex != null) {
throw new IllegalArgumentException("Method " + method.name() + " of Repository " + repositoryClassInfo
+ "has invalid parameters - only a single dynamic projection parameter of type "
+ DotNames.CLASS + " can be specified");
}
dynamicProjectionParameterIndex = i;
} else {
queryParameterIndexes.add(i);
}
}
MethodNameParser.Result parseResult = methodNameParser.parse(method);
if (parseResult.getParamCount() != queryParameterIndexes.size()) {View on GitHub (pinned to e1c734241f)
Solutions
- Keep only one Sort parameter and combine criteria: Sort.by(Order.desc("a"), Order.asc("b"))
- Remove redundant Sort parameters
- Use Pageable (which carries a Sort) if paging plus sorting is needed
- Add @Query with explicit ORDER BY if sorting is fixed
Example fix
// before
List<User> findByName(String n, Sort s1, Sort s2);
// after
List<User> findByName(String n, Sort s); // Sort.by(desc("age"), asc("name")) Defensive patterns
Strategy: validation
Validate before calling
long sortCount = Arrays.stream(m.getParameterTypes())
.filter(t -> Sort.class.isAssignableFrom(t)).count(); Prevention
- One Sort parameter max per method
- Combine multiple orders with Sort.by(...)
- Prefer Pageable when both paging and sorting are needed
When it happens
Trigger: Declaring e.g. List<User> findByName(String n, Sort s1, Sort s2); the second Sort parameter triggers the throw.
Common situations: Merging two method signatures during refactor; copying a signature that passed primary and secondary sort objects; confusion between Sort and Order criteria.
Related errors
- Method ${method} of Repository ${repository}has invalid para
- Method ${method} of Repository ${repository}has invalid para
- Method ${repositoryMethodDescription} cannot be parsed. Did
- Return type of method ${methodName} of Repository ${reposito
- ${t.name()} is not in the Quarkus Jandex index and cannot be
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/93f220c0533c3503.
Report an issue: GitHub.