Skip to content

Commit a8a37d4

Browse files
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.
1 parent e019ed1 commit a8a37d4

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/main/java/org/springframework/data/keyvalue/repository/support/KeyValueRepositoryFactory.java

+4-10
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
2929
import org.springframework.data.repository.core.EntityInformation;
3030
import org.springframework.data.repository.core.NamedQueries;
31+
import org.springframework.data.repository.core.RepositoryInformation;
3132
import org.springframework.data.repository.core.RepositoryMetadata;
3233
import org.springframework.data.repository.core.support.PersistentEntityInformation;
3334
import org.springframework.data.repository.core.support.RepositoryFactorySupport;
@@ -38,7 +39,6 @@
3839
import org.springframework.data.repository.query.RepositoryQuery;
3940
import org.springframework.data.repository.query.parser.AbstractQueryCreator;
4041
import org.springframework.util.Assert;
41-
import org.springframework.util.ClassUtils;
4242

4343
/**
4444
* {@link RepositoryFactorySupport} specific of handing
@@ -101,16 +101,10 @@ public <T, ID extends Serializable> EntityInformation<T, ID> getEntityInformatio
101101
* @see org.springframework.data.repository.core.support.RepositoryFactorySupport#getTargetRepository(org.springframework.data.repository.core.RepositoryMetadata)
102102
*/
103103
@Override
104-
@SuppressWarnings({ "unchecked", "rawtypes" })
105-
protected Object getTargetRepository(RepositoryMetadata metadata) {
104+
protected Object getTargetRepository(RepositoryInformation repositoryInformation) {
106105

107-
EntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType());
108-
109-
if (ClassUtils.isAssignable(QueryDslPredicateExecutor.class, metadata.getRepositoryInterface())) {
110-
return new QuerydslKeyValueRepository(entityInformation, keyValueOperations);
111-
}
112-
113-
return new SimpleKeyValueRepository(entityInformation, keyValueOperations);
106+
EntityInformation<?, Serializable> entityInformation = getEntityInformation(repositoryInformation.getDomainType());
107+
return super.getTargetRepositoryViaReflection(repositoryInformation, entityInformation, keyValueOperations);
114108
}
115109

116110
/*

src/main/java/org/springframework/data/map/repository/config/EnableMapRepositories.java

+8
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.springframework.data.keyvalue.repository.config.QueryCreatorType;
3434
import org.springframework.data.keyvalue.repository.query.SpelQueryCreator;
3535
import org.springframework.data.keyvalue.repository.support.KeyValueRepositoryFactoryBean;
36+
import org.springframework.data.repository.config.DefaultRepositoryBaseClass;
3637
import org.springframework.data.repository.query.QueryLookupStrategy;
3738
import org.springframework.data.repository.query.QueryLookupStrategy.Key;
3839

@@ -113,6 +114,13 @@
113114
*/
114115
Class<?> repositoryFactoryBeanClass() default KeyValueRepositoryFactoryBean.class;
115116

117+
/**
118+
* Configure the repository base class to be used to create repository proxies for this particular configuration.
119+
*
120+
* @return
121+
*/
122+
Class<?> repositoryBaseClass() default DefaultRepositoryBaseClass.class;
123+
116124
/**
117125
* Configures the name of the {@link KeyValueOperations} bean to be used with the repositories detected.
118126
*

0 commit comments

Comments
 (0)