quarkusio/quarkus · error · UnableToParseMethodException
Method ${repositoryMethodDescription} cannot be parsed as th
Error message
Method ${repositoryMethodDescription} cannot be parsed as there is no proper 'By' clause in the name. What it means
MethodNameParser requires a 'By' separator followed by criteria to split the method name into predicate parts. When the derived-query method name contains no 'By' (or 'By' is the last token), parsing fails with UnableToParseMethodException.
Source
Thrown at extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/MethodNameParser.java:101
public Result parse(MethodInfo methodInfo) {
String methodName = methodInfo.name();
ClassInfo repositoryClassInfo = methodInfo.declaringClass();
String repositoryMethodDescription = "'" + methodName + "' of repository '" + repositoryClassInfo + "'";
QueryType queryType = getType(methodName);
String entityAlias = getEntityName().toLowerCase();
// The SELECT clause is necessary after https://hibernate.atlassian.net/browse/HHH-18584
String selectClause = queryType == QueryType.SELECT ? "SELECT " + entityAlias + " " : "";
String fromClause = "FROM " + getEntityName() + " AS " + entityAlias;
String joinClause = "";
if (queryType == null) {
throw new UnableToParseMethodException("Method " + repositoryMethodDescription
+ " cannot be parsed. Did you forget to annotate the method with '@Query'?");
}
int byIndex = methodName.indexOf("By");
if ((byIndex == -1) || (byIndex + 2 >= methodName.length())) {
throw new UnableToParseMethodException("Method " + repositoryMethodDescription
+ " cannot be parsed as there is no proper 'By' clause in the name.");
}
// handle 'Top' and 'First'
Integer topCount = null;
int minFirstOrTopIndex = Math.min(indexOfOrMaxValue(methodName, "First"), indexOfOrMaxValue(methodName, "Top"));
// 'First' and 'Top' could be part of a field name, so we only consider them as part of a top query
// if they are found before 'By'
if (minFirstOrTopIndex < byIndex) {
if (queryType != QueryType.SELECT) {
throw new UnableToParseMethodException(
"When 'Top' or 'First' is specified, the query must be a find query. Offending method is "
+ repositoryMethodDescription + ".");
}
try {
String topCountStr = methodName.substring(minFirstOrTopIndex, byIndex)
.replace("Top", "").replace("First", "");
if (topCountStr.isEmpty()) {View on GitHub (pinned to e1c734241f)
Solutions
- Add criteria after 'By', e.g. findAll -> findAllBy... or better use @Query for unfiltered selects
- For no-filter queries use @Query("FROM User") or count/delete variants with explicit @Query
- Remove the trailing dangling 'By' from the method name
- Implement the method in a custom repository fragment (Entity_Manager delegate) instead
Example fix
// before
List<User> findAll();
// after
@Query("FROM User")
List<User> findAll(); Defensive patterns
Strategy: validation
Validate before calling
// method name must contain 'By' with criteria after it
boolean ok = methodName.contains("By")
&& methodName.indexOf("By") + 2 < methodName.length(); Try / catch
// Build-time failure; fix by adding criteria or @Query:
// @Query("FROM User") List<User> findAll(); Prevention
- Don't expect findAll()/getAll() to be derived — use @Query or a base repository
- Never leave a dangling 'By' at the end of a method name
- Lint repo interfaces for the By-clause pattern
When it happens
Trigger: Methods like `List<User> findAll();` in a Spring-style derived query repo (not supported here without @Query), or `findByNameBy` / `findByNameBy` with 'By' at the end — byIndex == -1 or byIndex+2 >= methodName.length().
Common situations: findAll()/getAll() declared expecting Spring Data's built-in handling; typo leaving a dangling 'By' (e.g. `findBy`); generated method names truncated.
Related errors
- Method ${repositoryMethodDescription} cannot be parsed. Did
- When 'Top' or 'First' is specified, the query must be a find
- Unable to parse query with limiting results clause. Offendin
- The number of parameters of method ${method} of Repository $
- Distinct is not yet supported. Offending method is ${reposit
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/4aeb3e829701bf49.
Report an issue: GitHub.