quarkusio/quarkus · error · IllegalArgumentException
Repository ${repository} specifies multiple Entity types
Error message
Repository ${repository} specifies multiple Entity types What it means
A single repository hierarchy must commit to exactly one entity type. When Quarkus walks all Spring Data repository interfaces extended by the repository (e.g. both Repository and CrudRepository, or multiple parents), it compares the resolved entity type from each; a mismatch means the repository (or a base interface) specifies two different entity types, which cannot be implemented.
Source
Thrown at extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/generate/SpringDataRepositoryCreator.java:159
return new AbstractMap.SimpleEntry<>(repositoryDefinitionInstance.value("idClass").asClass().name(),
repositoryDefinitionInstance.value("domainClass").asClass().name());
}
DotName entityDotName = null;
DotName idDotName = null;
// we need to pull the entity and ID types for the Spring Data generic types
// we also need to make sure that the user didn't try to specify multiple different types
// in the same interface (which is possible if only Repository is used)
for (DotName extendedSpringDataRepo : GenerationUtil.extendedSpringDataRepos(repositoryToImplement, indexView)) {
List<Type> types = JandexUtil.resolveTypeParameters(repositoryToImplement.name(), extendedSpringDataRepo, index);
if (!(types.get(0) instanceof ClassType)) {
throw new IllegalArgumentException(
"Entity generic argument of " + repositoryToImplement + " is not a regular class type");
}
DotName newEntityDotName = types.get(0).name();
if ((entityDotName != null) && !newEntityDotName.equals(entityDotName)) {
throw new IllegalArgumentException("Repository " + repositoryToImplement + " specifies multiple Entity types");
}
entityDotName = newEntityDotName;
DotName newIdDotName = types.get(1).name();
if ((idDotName != null) && !newIdDotName.equals(idDotName)) {
throw new IllegalArgumentException("Repository " + repositoryToImplement + " specifies multiple ID types");
}
idDotName = newIdDotName;
}
if (idDotName == null || entityDotName == null) {
throw new IllegalArgumentException(
"Repository " + repositoryToImplement + " does not specify ID and/or Entity type");
}
return new AbstractMap.SimpleEntry<>(idDotName, entityDotName);
}
View on GitHub (pinned to e1c734241f)
Solutions
- Ensure every Spring Data interface the repository extends is parameterized with the same entity class
- If multiple entities are needed, declare separate repository interfaces — one per entity
- Check intermediate/parent interfaces in the hierarchy for stale generic parameters
Example fix
// before
interface FooRepo extends CrudRepository<Foo, Long>, Repository<Bar, Long> { }
// after
interface FooRepo extends CrudRepository<Foo, Long> { }
interface BarRepo extends CrudRepository<Bar, Long> { } Defensive patterns
Strategy: validation
Validate before calling
// All parents must share the same entity type
// before building, grep the hierarchy:
// interface UserRepo extends CrudRepository<User, Long>, Repository<User, Long> { } // OK
// mismatched entities will fail augmentation Prevention
- One repository interface per entity
- Keep parent Spring Data interfaces' generics in sync when refactoring
- Avoid diamond inheritance of Spring Data interfaces
When it happens
Trigger: A repository extends two Spring Data interfaces parameterized with different entities (e.g. CrudRepository<A, Long> and Repository<B, Long>); or an intermediate interface re-parameterizes the entity differently.
Common situations: Copy-paste of base repository interfaces with diverging generics; diamond inheritance where one branch fixes the entity to a different class; refactoring that changed the entity in only one of several parent interfaces.
Related errors
- Entity generic argument of ${repository} is not a regular cl
- Repository ${repository} specifies multiple ID types
- Repository ${repository} does not specify ID and/or Entity t
- Unsupported wildcard type: ${wildcard}
- Invalid type:
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/e43cdcb45aa19874.
Report an issue: GitHub.