{"record":{"id":"e43cdcb45aa19874","repo":"quarkusio/quarkus","slug":"repository-repository-specifies-multiple-entity","errorCode":null,"errorMessage":"Repository ${repository} specifies multiple Entity types","messagePattern":"Repository (.+?) specifies multiple Entity types","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/generate/SpringDataRepositoryCreator.java","lineNumber":159,"sourceCode":"            return new AbstractMap.SimpleEntry<>(repositoryDefinitionInstance.value(\"idClass\").asClass().name(),\n                    repositoryDefinitionInstance.value(\"domainClass\").asClass().name());\n        }\n\n        DotName entityDotName = null;\n        DotName idDotName = null;\n\n        // we need to pull the entity and ID types for the Spring Data generic types\n        // we also need to make sure that the user didn't try to specify multiple different types\n        // in the same interface (which is possible if only Repository is used)\n        for (DotName extendedSpringDataRepo : GenerationUtil.extendedSpringDataRepos(repositoryToImplement, indexView)) {\n            List<Type> types = JandexUtil.resolveTypeParameters(repositoryToImplement.name(), extendedSpringDataRepo, index);\n            if (!(types.get(0) instanceof ClassType)) {\n                throw new IllegalArgumentException(\n                        \"Entity generic argument of \" + repositoryToImplement + \" is not a regular class type\");\n            }\n            DotName newEntityDotName = types.get(0).name();\n            if ((entityDotName != null) && !newEntityDotName.equals(entityDotName)) {\n                throw new IllegalArgumentException(\"Repository \" + repositoryToImplement + \" specifies multiple Entity types\");\n            }\n            entityDotName = newEntityDotName;\n\n            DotName newIdDotName = types.get(1).name();\n            if ((idDotName != null) && !newIdDotName.equals(idDotName)) {\n                throw new IllegalArgumentException(\"Repository \" + repositoryToImplement + \" specifies multiple ID types\");\n            }\n            idDotName = newIdDotName;\n        }\n\n        if (idDotName == null || entityDotName == null) {\n            throw new IllegalArgumentException(\n                    \"Repository \" + repositoryToImplement + \" does not specify ID and/or Entity type\");\n        }\n\n        return new AbstractMap.SimpleEntry<>(idDotName, entityDotName);\n    }\n","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/generate/SpringDataRepositoryCreator.java#L141-L177","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\ninterface FooRepo extends CrudRepository<Foo, Long>, Repository<Bar, Long> { }\n// after\ninterface FooRepo extends CrudRepository<Foo, Long> { }\ninterface BarRepo extends CrudRepository<Bar, Long> { }","handlingStrategy":"validation","validationCode":"// All parents must share the same entity type\n// before building, grep the hierarchy:\n// interface UserRepo extends CrudRepository<User, Long>, Repository<User, Long> { } // OK\n// mismatched entities will fail augmentation","typeGuard":null,"tryCatchPattern":null,"preventionTips":["One repository interface per entity","Keep parent Spring Data interfaces' generics in sync when refactoring","Avoid diamond inheritance of Spring Data interfaces"],"tags":["quarkus","spring-data-jpa","generics","build-time"],"backgroundTag":"invalid-generic-type-parameter","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}