quarkusio/quarkus · error · IllegalArgumentException

Repository ${repository} does not specify ID and/or Entity t

Error message

Repository ${repository} does not specify ID and/or Entity type

What it means

After walking the repository hierarchy, Quarkus requires both the entity and ID type parameters to be resolvable. If either is missing (null), the repository did not extend any Spring Data repository interface with proper <Entity, ID> generics, so no CRUD methods can be generated.

Source

Thrown at extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/generate/SpringDataRepositoryCreator.java:171

            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);
    }

    private void createCustomImplFields(io.quarkus.gizmo2.creator.ClassCreator repositoryImpl,
            List<DotName> customInterfaceNamesToImplement,
            IndexView index, Map<String, FieldDesc> customImplNameToFieldDescriptor) {
        Set<String> customImplClassNames = new HashSet<>(customInterfaceNamesToImplement.size());

        // go through the interfaces and collect the implementing classes in a Set
        // this is done because it is possible for an implementing class to implement multiple fragments
        for (DotName customInterfaceToImplement : customInterfaceNamesToImplement) {
            customImplClassNames
                    .add(FragmentMethodsUtil.getImplementationDotName(customInterfaceToImplement, index).toString());
        }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Extend a Spring Data repository interface with explicit generics: interface UserRepo extends CrudRepository<User, Long>
  2. Ensure both the entity and ID type arguments are concrete classes
  3. Remove raw-type declarations of Repository/CrudRepository

Example fix

// before
public interface UserRepo extends Repository { }
// after
public interface UserRepo extends CrudRepository<User, Long> { }
Defensive patterns

Strategy: validation

Validate before calling

// A repository must extend a Spring Data base interface with concrete generics
if (!(repo instanceof CrudRepository) && !(repo instanceof Repository))
    throw new IllegalStateException("Repository must extend CrudRepository/Repository with <Entity, ID>");

Prevention

When it happens

Trigger: A repository interface declares no generics or leaves them unbound (raw type), e.g. interface MyRepo extends Repository; or it extends only a custom fragment interface without any Spring Data base interface.

Common situations: Raw-type usage after refactoring; forgetting to extend CrudRepository/Repository/JpaRepository; a generic base whose type parameters were never concretized.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/7808bca03d2f4857. Report an issue: GitHub.