quarkusio/quarkus · error · IllegalArgumentException
${field} method does not exists in ${entity} class.
Error message
${field} method does not exists in ${entity} class. What it means
When generating the implementation of an interface projection, the spring-data-jpa extension populates each projected property by invoking the corresponding getter on the entity. If the entity class has no getter for a projected property (getterExists fails over the entity's available methods), the generated code would be broken, so the build fails with this IllegalArgumentException naming the missing getter and the entity class.
Source
Thrown at extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/generate/DerivedMethodsAdder.java:479
}
// Add static methods to convert from entity to this type
for (String queryMethod : queryMethods) {
MethodTypeDesc convertMtd = GenerationUtil.toMethodTypeDesc(implName.toString(),
entityClassInfo.name().toString());
implClassCreator.staticMethod("convert_" + queryMethod, smc -> {
smc.setType(convertMtd);
smc.public_();
ParamVar entityParam = smc.parameter("entity");
smc.body(bc -> {
LocalVar newObject = bc.localVar("newObject",
bc.new_(ClassDesc.of(implName.toString())));
final List<MethodInfo> availableMethods = availableMethods(entityClassInfo, index);
for (Map.Entry<String, FieldDesc> field : fields.entrySet()) {
if (!getterExists(availableMethods, field.getKey())) {
throw new IllegalArgumentException(field.getKey() + " method does not exists in "
+ entityClassInfo.name().toString() + " class.");
}
FieldDesc f = field.getValue();
Expr getterResult = bc.invokeVirtual(
ClassMethodDesc.of(ClassDesc.of(entityClassInfo.name().toString()), field.getKey(),
MethodTypeDesc.of(f.type())),
entityParam);
bc.set(newObject.field(f), getterResult);
}
bc.return_(newObject);
});
});
}
});
}
private static List<MethodInfo> availableMethods(ClassInfo entityClassInfo, IndexView index) {View on GitHub (pinned to e1c734241f)
Solutions
- Align the projection getter name with the entity's actual getter (e.g. rename getFullName() to match, or update the projection to getFullName())
- Add the missing getter to the entity if the property genuinely exists
- Remove the property from the projection interface if it has no entity counterpart
- For computed values, expose them via @Query with a select expression instead of an interface projection
Example fix
// before
class Person { public String getFullName() { ... } }
interface PersonView { String getName(); }
// after
class Person { public String getFullName() { ... } }
interface PersonView { String getFullName(); } Defensive patterns
Strategy: validation
Validate before calling
// Check each projection getter has a matching entity getter before building
static void checkProjectionAgainstEntity(Class<?> ifc, Class<?> entity) {
for (Method m : ifc.getDeclaredMethods()) {
try {
entity.getMethod(m.getName());
} catch (NoSuchMethodException e) {
throw new IllegalStateException(m.getName() + " missing on entity " + entity.getName());
}
}
} Prevention
- Derive projection interfaces from the entity's getters (copy names verbatim)
- When renaming entity fields, search all projection interfaces for the old getter name
- Add a reflection-based startup/test assertion that projections match entities
When it happens
Trigger: Declaring a projection interface with e.g. String getName(); while the entity only exposes getFullName(), or a property typed differently without its own getter (e.g. getAddress() when only getHomeAddress() exists) — any projected field whose getter name is absent from the entity's methods.
Common situations: Renaming an entity field/getter without updating projection interfaces; typos in the projection property name; projecting a computed/derived value that exists only in the DTO, not on the entity.
Related errors
- ${method} of Repository ${repository} can only use interface
- Method ${method} of interface ${interface} is not a getter m
- ${method} of Repository ${repository} contains both a Sort p
- ${method} of Repository ${repository} is meant to be a count
- ${method} of Repository ${repository} is meant to be a count
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/c958681d7de9fbf6.
Report an issue: GitHub.