quarkusio/quarkus · error · UnableToParseMethodException
A field must by supplied after 'OrderBy' . Offending method
Error message
A field must by supplied after 'OrderBy' . Offending method is ${repositoryMethodDescription}. What it means
When parsing the 'OrderBy' clause of a derived repository method name, the parser found 'OrderBy' as the last text with no field name following it. It throws UnableToParseMethodException because a sort field must be supplied after 'OrderBy'.
Source
Thrown at extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/MethodNameParser.java:149
if (methodName.substring(0, byIndex).contains("Distinct")) {
throw new UnableToParseMethodException(
"Distinct is not yet supported. Offending method is " + repositoryMethodDescription + ".");
}
// handle 'AllIgnoreCase'
String afterByPart = methodName.substring(byIndex + 2);
boolean allIgnoreCase = false;
if (afterByPart.contains(ALL_IGNORE_CASE)) {
allIgnoreCase = true;
afterByPart = afterByPart.replace(ALL_IGNORE_CASE, "");
}
// handle the 'OrderBy' clause which is assumed to be at the end of the query
Sort sort = null;
if (containsLogicOperator(afterByPart, ORDER_BY)) {
int orderByIndex = afterByPart.indexOf(ORDER_BY);
if (orderByIndex + ORDER_BY.length() == afterByPart.length()) {
throw new UnableToParseMethodException(
"A field must by supplied after 'OrderBy' . Offending method is " + repositoryMethodDescription + ".");
}
String afterOrderByPart = afterByPart.substring(orderByIndex + ORDER_BY.length());
afterByPart = afterByPart.substring(0, orderByIndex);
boolean ascending = true;
if (afterOrderByPart.endsWith("Asc")) {
ascending = true;
afterOrderByPart = afterOrderByPart.replace("Asc", "");
} else if (afterOrderByPart.endsWith("Desc")) {
ascending = false;
afterOrderByPart = afterOrderByPart.replace("Desc", "");
}
String orderField = lowerFirstLetter(afterOrderByPart);
if (!entityContainsField(orderField)) {
throw new UnableToParseMethodException(
"Field " + orderField
+ " which was configured as the order field does not exist in the entity. Offending method is "
+ repositoryMethodDescription + ".");View on GitHub (pinned to e1c734241f)
Solutions
- Append the field name (and optionally Asc/Desc) after OrderBy: e.g. ...OrderByLastnameAsc
- Remove the OrderBy clause entirely if sorting is not needed and sort at call time with Sort.by(...) or a Pageable
Example fix
// before List<User> findByLastnameOrderBy(String lastname); // after List<User> findByLastnameOrderByLastnameAsc(String lastname);
Defensive patterns
Strategy: validation
Validate before calling
// Regex check in a unit test:
// assertTrue(methodName.matches(".*OrderBy[A-Z].*(Asc|Desc)?"), "OrderBy needs a field: " + methodName); Try / catch
try {
parser.parse(methodName);
} catch (UnableToParseMethodException e) {
// complete the OrderBy clause or drop it
log.error("Derived method incomplete: " + e.getMessage());
} Prevention
- Always follow OrderBy with a field name, optionally suffixed Asc/Desc
- Run a QuarkusTest that boots the app — all repository methods are parsed at startup/build
- Don't truncate long method names during refactoring
When it happens
Trigger: Declaring a method ending exactly in 'OrderBy' (e.g. findAllByLastnameOrderBy, findByAgeOrderBy) — the substring after 'OrderBy' is empty.
Common situations: Typo or truncation while renaming methods; deleting the sort field during refactoring; copy-paste of method names that got cut off at the end.
Related errors
- Distinct is not yet supported. Offending method is ${reposit
- Field ${orderField} which was configured as the order field
- IgnoreCase cannot be specified for field${fieldInfo.name()}
- fieldNotResolvableMessage + offendingMethodMessage
- fieldNotResolvableMessage + detail + offendingMethodMessage
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/03bf3aa2e1d061c2.
Report an issue: GitHub.