DATACMNS-376 - Repositories now inspects user class for factory lookups.

When looking up the RepositoryFactoryInformation for a domain type we now make sure we look up the user type to not accidentally try to do so for a persistence provider generated proxy class for the original type. This prevents us from not finding PersistentEntity instances, Repository- or EntityInformation accidentally.
This commit is contained in:
Oliver Gierke
2013-10-01 17:24:42 +02:00
parent e7475e5e0f
commit 59e9af4950
2 changed files with 15 additions and 2 deletions

View File

@@ -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<Class<?>> {
// Create defensive copy of the keys to allow threads to potentially add values while iterating over them
Set<RepositoryFactoryInformation<Object, Serializable>> keys = Collections.unmodifiableSet(repositories.keySet());
Class<?> type = ClassUtils.getUserClass(domainClass);
for (RepositoryFactoryInformation<Object, Serializable> information : keys) {
if (domainClass.equals(information.getEntityInformation().getJavaType())) {
if (type.equals(information.getEntityInformation().getJavaType())) {
return information;
}
}
return lookupRepositoryFactoryInformationFor(domainClass);
return lookupRepositoryFactoryInformationFor(type);
}
/*