Repository: quarkusio/quarkus
Issue: Exception when using a custom interface in Spring Data JPA

Mentioned in #4104,  the issue is still in 1.0.0.CR1. 

Repository codes https://github.com/hantsy/quarkus-sandbox/blob/master/spring-post-service/src/main/java/com/example/PostRepository.java#L6

```bash
12:31:52,971 ERROR [io.qua.dev.DevModeMain] Failed to start Quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.AmbiguousResolutionException: Ambiguous dependencies for type com.example.PostRepositoryImpl and qualifiers [@Default]
        - java member: com.example.PostRepositoryImpl#customImplClass1
        - declared on CLASS bean [types=[com.example.PostRepositoryImpl, org.springframework.data.jpa.repository.JpaRepository<com.example.Post, java.lang.String>, org.springframework.data.repository.query.QueryByExampleExecutor<com.example.Post>, org.springframework.data.repository.CrudRepository<com.example.Post, java.lang.String>, com.example.PostRepository, org.springframework.data.repository.Repository<com.example.Post, java.lang.String>, java.lang.Object, com.example.PostRepositoryCustom, org.springframework.data.repository.PagingAndSortingRepository<com.example.Post, java.lang.String>], qualifiers=[@Default, @Any], target=com.example.PostRepositoryImpl]
        - available beans:
                - CLASS bean [types=[com.example.PostRepositoryImpl, org.springframework.data.jpa.repository.JpaRepository<com.example.Post, java.lang.String>, org.springframework.data.repository.query.QueryByExampleExecutor<com.example.Post>, org.springframework.data.repository.CrudRepository<com.example.Post, java.lang.String>, com.example.PostRepository, org.springframework.data.repository.Repository<com.example.Post, java.lang.String>, java.lang.Object, com.example.PostRepositoryCustom, org.springframework.data.repository.PagingAndSortingRepository<com.example.Post, java.lang.String>], qualifiers=[@Default, @Any], target=com.example.PostRepositoryImpl]
                - CLASS bean [types=[com.example.PostRepositoryImpl, java.lang.Object, com.example.PostRepositoryCustom], qualifiers=[@Default, @Any], target=com.example.PostRepositoryImpl]
        at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:850)
        at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:220)
        at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:106)
        at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:251)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at io.quarkus.deployment.ExtensionLoader$1.execute(ExtensionLoader.java:941)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:415)
        at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426)
        at java.base/java.lang.Thread.run(Thread.java:834)
        at org.jboss.threads.JBossThread.run(JBossThread.java:479)
Caused by: javax.enterprise.inject.AmbiguousResolutionException: Ambiguous dependencies for type com.example.PostRepositoryImpl and qualifiers [@Default]
        - java member: com.example.PostRepositoryImpl#customImplClass1
        - declared on CLASS bean [types=[com.example.PostRepositoryImpl, org.springframework.data.jpa.repository.JpaRepository<com.example.Post, java.lang.String>, org.springframework.data.repository.query.QueryByExampleExecutor<com.example.Post>, org.springframework.data.repository.CrudRepository<com.example.Post, java.lang.String>, com.example.PostRepository, org.springframework.data.repository.Repository<com.example.Post, java.lang.String>, java.lang.Object, com.example.PostRepositoryCustom, org.springframework.data.repository.PagingAndSortingRepository<com.example.Post, java.lang.String>], qualifiers=[@Default, @Any], target=com.example.PostRepositoryImpl]
        - available beans:
                - CLASS bean [types=[com.example.PostRepositoryImpl, org.springframework.data.jpa.repository.JpaRepository<com.example.Post, java.lang.String>, org.springframework.data.repository.query.QueryByExampleExecutor<com.example.Post>, org.springframework.data.repository.CrudRepository<com.example.Post, java.lang.String>, com.example.PostRepository, org.springframework.data.repository.Repository<com.example.Post, java.lang.String>, java.lang.Object, com.example.PostRepositoryCustom, org.springframework.data.repository.PagingAndSortingRepository<com.example.Post, java.lang.String>], qualifiers=[@Default, @Any], target=com.example.PostRepositoryImpl]
                - CLASS bean [types=[com.example.PostRepositoryImpl, java.lang.Object, com.example.PostRepositoryCustom], qualifiers=[@Default, @Any], target=com.example.PostRepositoryImpl]
        at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:487)
        at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:404)
        at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:212)
        ... 14 more

        at io.quarkus.runner.RuntimeRunner.run(RuntimeRunner.java:157)
        at io.quarkus.dev.DevModeMain.doStart(DevModeMain.java:177)
        at io.quarkus.dev.DevModeMain.start(DevModeMain.java:95)
        at io.quarkus.dev.DevModeMain.main(DevModeMain.java:66)
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.AmbiguousResolutionException: Ambiguous dependencies for type com.example.PostRepositoryImpl and qualifiers [@Default]
        - java member: com.example.PostRepositoryImpl#customImplClass1
        - declared on CLASS bean [types=[com.example.PostRepositoryImpl, org.springframework.data.jpa.repository.JpaRepository<com.example.Post, java.lang.String>, org.springframework.data.repository.query.QueryByExampleExecutor<com.example.Post>, org.springframework.data.repository.CrudRepository<com.example.Post, java.lang.String>, com.example.PostRepository, org.springframework.data.repository.Repository<com.example.Post, java.lang.String>, java.lang.Object, com.example.PostRepositoryCustom, org.springframework.data.repository.PagingAndSortingRepository<com.example.Post, java.lang.String>], qualifiers=[@Default, @Any], target=com.example.PostRepositoryImpl]
        - available beans:
                - CLASS bean [types=[com.example.PostRepositoryImpl, org.springframework.data.jpa.repository.JpaRepository<com.example.Post, java.lang.String>, org.springframework.data.repository.query.QueryByExampleExecutor<com.example.Post>, org.springframework.data.repository.CrudRepository<com.example.Post, java.lang.String>, com.example.PostRepository, org.springframework.data.repository.Repository<com.example.Post, java.lang.String>, java.lang.Object, com.example.PostRepositoryCustom, org.springframework.data.repository.PagingAndSortingRepository<com.example.Post, java.lang.String>], qualifiers=[@Default, @Any], target=com.example.PostRepositoryImpl]
                - CLASS bean [types=[com.example.PostRepositoryImpl, java.lang.Object, com.example.PostRepositoryCustom], qualifiers=[@Default, @Any], target=com.example.PostRepositoryImpl]
        at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:850)
        at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:220)
        at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:106)
        at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:251)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at io.quarkus.deployment.ExtensionLoader$1.execute(ExtensionLoader.java:941)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:415)
        at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426)
        at java.base/java.lang.Thread.run(Thread.java:834)
        at org.jboss.threads.JBossThread.run(JBossThread.java:479)
Caused by: javax.enterprise.inject.AmbiguousResolutionException: Ambiguous dependencies for type com.example.PostRepositoryImpl and qualifiers [@Default]
        - java member: com.example.PostRepositoryImpl#customImplClass1
        - declared on CLASS bean [types=[com.example.PostRepositoryImpl, org.springframework.data.jpa.repository.JpaRepository<com.example.Post, java.lang.String>, org.springframework.data.repository.query.QueryByExampleExecutor<com.example.Post>, org.springframework.data.repository.CrudRepository<com.example.Post, java.lang.String>, com.example.PostRepository, org.springframework.data.repository.Repository<com.example.Post, java.lang.String>, java.lang.Object, com.example.PostRepositoryCustom, org.springframework.data.repository.PagingAndSortingRepository<com.example.Post, java.lang.String>], qualifiers=[@Default, @Any], target=com.example.PostRepositoryImpl]
        - available beans:
                - CLASS bean [types=[com.example.PostRepositoryImpl, org.springframework.data.jpa.repository.JpaRepository<com.example.Post, java.lang.String>, org.springframework.data.repository.query.QueryByExampleExecutor<com.example.Post>, org.springframework.data.repository.CrudRepository<com.example.Post, java.lang.String>, com.example.PostRepository, org.springframework.data.repository.Repository<com.example.Post, java.lang.String>, java.lang.Object, com.example.PostRepositoryCustom, org.springframework.data.repository.PagingAndSortingRepository<com.example.Post, java.lang.String>], qualifiers=[@Default, @Any], target=com.example.PostRepositoryImpl]
                - CLASS bean [types=[com.example.PostRepositoryImpl, java.lang.Object, com.example.PostRepositoryCustom], qualifiers=[@Default, @Any], target=com.example.PostRepositoryImpl]
        at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:487)
        at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:404)
        at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:212)
        ... 14 more

        at io.quarkus.builder.Execution.run(Execution.java:108)
        at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:121)
        at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:130)
        at io.quarkus.runner.RuntimeRunner.run(RuntimeRunner.java:111)
        ... 3 more
Caused by: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.AmbiguousResolutionException: Ambiguous dependencies for type com.example.PostRepositoryImpl and qualifiers [@Default]
        - java member: com.example.PostRepositoryImpl#customImplClass1
        - declared on CLASS bean [types=[com.example.PostRepositoryImpl, org.springframework.data.jpa.repository.JpaRepository<com.example.Post, java.lang.String>, org.springframework.data.repository.query.QueryByExampleExecutor<com.example.Post>, org.springframework.data.repository.CrudRepository<com.example.Post, java.lang.String>, com.example.PostRepository, org.springframework.data.repository.Repository<com.example.Post, java.lang.String>, java.lang.Object, com.example.PostRepositoryCustom, org.springframework.data.repository.PagingAndSortingRepository<com.example.Post, java.lang.String>], qualifiers=[@Default, @Any], target=com.example.PostRepositoryImpl]
        - available beans:
                - CLASS bean [types=[com.example.PostRepositoryImpl, org.springframework.data.jpa.repository.JpaRepository<com.example.Post, java.lang.String>, org.springframework.data.repository.query.QueryByExampleExecutor<com.example.Post>, org.springframework.data.repository.CrudRepository<com.example.Post, java.lang.String>, com.example.PostRepository, org.springframework.data.repository.Repository<com.example.Post, java.lang.String>, java.lang.Object, com.example.PostRepositoryCustom, org.springframework.data.repository.PagingAndSortingRepository<com.example.Post, java.lang.String>], qualifiers=[@Default, @Any], target=com.example.PostRepositoryImpl]
                - CLASS bean [types=[com.example.PostRepositoryImpl, java.lang.Object, com.example.PostRepositoryCustom], qualifiers=[@Default, @Any], target=com.example.PostRepositoryImpl]
        at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:850)
        at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:220)
        at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:106)
        at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:251)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at io.quarkus.deployment.ExtensionLoader$1.execute(ExtensionLoader.java:941)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:415)
        at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426)
        at java.base/java.lang.Thread.run(Thread.java:834)
        at org.jboss.threads.JBossThread.run(JBossThread.java:479)
Caused by: javax.enterprise.inject.AmbiguousResolutionException: Ambiguous dependencies for type com.example.PostRepositoryImpl and qualifiers [@Default]
        - java member: com.example.PostRepositoryImpl#customImplClass1
        - declared on CLASS bean [types=[com.example.PostRepositoryImpl, org.springframework.data.jpa.repository.JpaRepository<com.example.Post, java.lang.String>, org.springframework.data.repository.query.QueryByExampleExecutor<com.example.Post>, org.springframework.data.repository.CrudRepository<com.example.Post, java.lang.String>, com.example.PostRepository, org.springframework.data.repository.Repository<com.example.Post, java.lang.String>, java.lang.Object, com.example.PostRepositoryCustom, org.springframework.data.repository.PagingAndSortingRepository<com.example.Post, java.lang.String>], qualifiers=[@Default, @Any], target=com.example.PostRepositoryImpl]
        - available beans:
                - CLASS bean [types=[com.example.PostRepositoryImpl, org.springframework.data.jpa.repository.JpaRepository<com.example.Post, java.lang.String>, org.springframework.data.repository.query.QueryByExampleExecutor<com.example.Post>, org.springframework.data.repository.CrudRepository<com.example.Post, java.lang.String>, com.example.PostRepository, org.springframework.data.repository.Repository<com.example.Post, java.lang.String>, java.lang.Object, com.example.PostRepositoryCustom, org.springframework.data.repository.PagingAndSortingRepository<com.example.Post, java.lang.String>], qualifiers=[@Default, @Any], target=com.example.PostRepositoryImpl]
                - CLASS bean [types=[com.example.PostRepositoryImpl, java.lang.Object, com.example.PostRepositoryCustom], qualifiers=[@Default, @Any], target=com.example.PostRepositoryImpl]
        at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:487)
        at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:404)
        at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:212)
        ... 14 more
```


Changed files:
extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/generate/SpringDataRepositoryCreator.java
integration-tests/spring-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/PersonFragmentImpl.java

diff --git a/extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/generate/SpringDataRepositoryCreator.java b/extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/generate/SpringDataRepositoryCreator.java
index 7ae0f5aa90c..582a6d404bd 100644
--- a/extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/generate/SpringDataRepositoryCreator.java
+++ b/extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/generate/SpringDataRepositoryCreator.java
@@ -19,6 +19,7 @@
 import org.jboss.jandex.IndexView;
 import org.jboss.jandex.Type;
 
+import io.quarkus.deployment.util.HashUtil;
 import io.quarkus.deployment.util.JandexUtil;
 import io.quarkus.gizmo.ClassCreator;
 import io.quarkus.gizmo.ClassOutput;
@@ -73,10 +74,11 @@ public void implementCrudRepository(ClassInfo repositoryToImplement) {
         }
 
         Map<String, FieldDescriptor> fragmentImplNameToFieldDescriptor = new HashMap<>();
-        String generatedClassName = repositoryToImplement.name().toString() + "Impl";
+        String repositoryToImplementStr = repositoryToImplement.name().toString();
+        String generatedClassName = repositoryToImplementStr + "_" + HashUtil.sha1(repositoryToImplementStr) + "Impl";
         try (ClassCreator classCreator = ClassCreator.builder().classOutput(classOutput)
                 .className(generatedClassName)
-                .interfaces(repositoryToImplement.name().toString())
+                .interfaces(repositoryToImplementStr)
                 .build()) {
             classCreator.addAnnotation(ApplicationScoped.class);
 
diff --git a/integration-tests/spring-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/PersonFragmentImpl.java b/integration-tests/spring-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/PersonRepositoryImpl.java
similarity index 87%
rename from integration-tests/spring-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/PersonFragmentImpl.java
rename to integration-tests/spring-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/PersonRepositoryImpl.java
index e05ceab2dc6..9495f483384 100644
--- a/integration-tests/spring-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/PersonFragmentImpl.java
+++ b/integration-tests/spring-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/PersonRepositoryImpl.java
@@ -5,7 +5,7 @@
 import javax.persistence.EntityManager;
 import javax.persistence.PersistenceContext;
 
-public class PersonFragmentImpl implements PersonFragment, PersonFragment2 {
+public class PersonRepositoryImpl implements PersonFragment, PersonFragment2 {
 
     @PersistenceContext
     EntityManager entityManager;