DATAKV-98 - Adapt to changes in Spring Data Commons.

Tweaked method signatures in KeyValueRepositoryFactory after some signature changes in Spring Data Commons. Use newly introduced getTragetRepositoryViaReflection(…) to obtain the repository instance via the super class.

Added repositoryBaseClass() attribute to @EnableMapRepositories.

Related tickets: DATACMNS-542.
This commit is contained in:
Christoph Strobl
2015-05-05 12:20:30 +02:00
parent e019ed1da8
commit a8a37d4a32
2 changed files with 12 additions and 10 deletions

View File

@@ -28,6 +28,7 @@ import org.springframework.data.mapping.context.MappingContext;
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
import org.springframework.data.repository.core.EntityInformation;
import org.springframework.data.repository.core.NamedQueries;
import org.springframework.data.repository.core.RepositoryInformation;
import org.springframework.data.repository.core.RepositoryMetadata;
import org.springframework.data.repository.core.support.PersistentEntityInformation;
import org.springframework.data.repository.core.support.RepositoryFactorySupport;
@@ -38,7 +39,6 @@ import org.springframework.data.repository.query.QueryMethod;
import org.springframework.data.repository.query.RepositoryQuery;
import org.springframework.data.repository.query.parser.AbstractQueryCreator;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
/**
* {@link RepositoryFactorySupport} specific of handing
@@ -101,16 +101,10 @@ public class KeyValueRepositoryFactory extends RepositoryFactorySupport {
* @see org.springframework.data.repository.core.support.RepositoryFactorySupport#getTargetRepository(org.springframework.data.repository.core.RepositoryMetadata)
*/
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
protected Object getTargetRepository(RepositoryMetadata metadata) {
protected Object getTargetRepository(RepositoryInformation repositoryInformation) {
EntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType());
if (ClassUtils.isAssignable(QueryDslPredicateExecutor.class, metadata.getRepositoryInterface())) {
return new QuerydslKeyValueRepository(entityInformation, keyValueOperations);
}
return new SimpleKeyValueRepository(entityInformation, keyValueOperations);
EntityInformation<?, Serializable> entityInformation = getEntityInformation(repositoryInformation.getDomainType());
return super.getTargetRepositoryViaReflection(repositoryInformation, entityInformation, keyValueOperations);
}
/*

View File

@@ -33,6 +33,7 @@ import org.springframework.data.keyvalue.core.KeyValueTemplate;
import org.springframework.data.keyvalue.repository.config.QueryCreatorType;
import org.springframework.data.keyvalue.repository.query.SpelQueryCreator;
import org.springframework.data.keyvalue.repository.support.KeyValueRepositoryFactoryBean;
import org.springframework.data.repository.config.DefaultRepositoryBaseClass;
import org.springframework.data.repository.query.QueryLookupStrategy;
import org.springframework.data.repository.query.QueryLookupStrategy.Key;
@@ -113,6 +114,13 @@ public @interface EnableMapRepositories {
*/
Class<?> repositoryFactoryBeanClass() default KeyValueRepositoryFactoryBean.class;
/**
* Configure the repository base class to be used to create repository proxies for this particular configuration.
*
* @return
*/
Class<?> repositoryBaseClass() default DefaultRepositoryBaseClass.class;
/**
* Configures the name of the {@link KeyValueOperations} bean to be used with the repositories detected.
*