diff --git a/src/main/java/org/springframework/data/repository/support/Repositories.java b/src/main/java/org/springframework/data/repository/support/Repositories.java index daa56e60e..d1d0437db 100644 --- a/src/main/java/org/springframework/data/repository/support/Repositories.java +++ b/src/main/java/org/springframework/data/repository/support/Repositories.java @@ -37,6 +37,7 @@ import org.springframework.data.repository.core.RepositoryInformation; import org.springframework.data.repository.core.support.RepositoryFactoryInformation; import org.springframework.data.repository.query.QueryMethod; import org.springframework.util.Assert; +import org.springframework.util.ClassUtils; /** * Wrapper class to access repository instances obtained from a {@link ListableBeanFactory}. @@ -175,14 +176,15 @@ public class Repositories implements Iterable> { // Create defensive copy of the keys to allow threads to potentially add values while iterating over them Set> keys = Collections.unmodifiableSet(repositories.keySet()); + Class type = ClassUtils.getUserClass(domainClass); for (RepositoryFactoryInformation information : keys) { - if (domainClass.equals(information.getEntityInformation().getJavaType())) { + if (type.equals(information.getEntityInformation().getJavaType())) { return information; } } - return lookupRepositoryFactoryInformationFor(domainClass); + return lookupRepositoryFactoryInformationFor(type); } /* diff --git a/src/test/java/org/springframework/data/repository/support/RepositoriesIntegrationTests.java b/src/test/java/org/springframework/data/repository/support/RepositoriesIntegrationTests.java index 08115648d..c3a244903 100644 --- a/src/test/java/org/springframework/data/repository/support/RepositoriesIntegrationTests.java +++ b/src/test/java/org/springframework/data/repository/support/RepositoriesIntegrationTests.java @@ -17,6 +17,7 @@ package org.springframework.data.repository.support; import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; +import static org.mockito.Mockito.*; import org.junit.Test; import org.junit.runner.RunWith; @@ -87,6 +88,16 @@ public class RepositoriesIntegrationTests { assertThat(repositories.getCrudInvoker(Product.class), is(instanceOf(ReflectionRepositoryInvoker.class))); } + /** + * @see DATACMNS-376 + */ + @Test + public void returnsPersistentEntityForProxiedClass() { + + User user = mock(User.class); + assertThat(repositories.getPersistentEntity(user.getClass()), is(notNullValue())); + } + static class User { }