1
1
/*
2
- * Copyright 2015 the original author or authors.
2
+ * Copyright 2015-2016 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
42
42
* {@link org.springframework.data.keyvalue.repository.KeyValueRepository}.
43
43
*
44
44
* @author Christoph Strobl
45
+ * @author Oliver Gierke
45
46
* @since 1.7
46
47
*/
47
48
public class RedisRepositoryFactory extends KeyValueRepositoryFactory {
48
49
50
+ private final KeyValueOperations operations ;
51
+ private final Class <? extends AbstractQueryCreator <?, ?>> queryCreator ;
52
+
49
53
/**
50
54
* @param keyValueOperations
51
55
* @see KeyValueRepositoryFactory#KeyValueRepositoryFactory(KeyValueOperations)
52
56
*/
53
57
public RedisRepositoryFactory (KeyValueOperations keyValueOperations ) {
54
- super (keyValueOperations );
58
+ this (keyValueOperations , DEFAULT_QUERY_CREATOR );
55
59
}
56
60
57
61
/**
@@ -62,6 +66,9 @@ public RedisRepositoryFactory(KeyValueOperations keyValueOperations) {
62
66
public RedisRepositoryFactory (KeyValueOperations keyValueOperations ,
63
67
Class <? extends AbstractQueryCreator <?, ?>> queryCreator ) {
64
68
super (keyValueOperations , queryCreator );
69
+
70
+ this .operations = keyValueOperations ;
71
+ this .queryCreator = queryCreator ;
65
72
}
66
73
67
74
/*
@@ -70,7 +77,7 @@ public RedisRepositoryFactory(KeyValueOperations keyValueOperations,
70
77
*/
71
78
@ Override
72
79
protected QueryLookupStrategy getQueryLookupStrategy (Key key , EvaluationContextProvider evaluationContextProvider ) {
73
- return new RedisQueryLookupStrategy (key , evaluationContextProvider , getKeyValueOperations (), getQueryCreator () );
80
+ return new RedisQueryLookupStrategy (key , evaluationContextProvider , operations , queryCreator );
74
81
}
75
82
76
83
/*
@@ -81,7 +88,8 @@ protected QueryLookupStrategy getQueryLookupStrategy(Key key, EvaluationContextP
81
88
@ SuppressWarnings ("unchecked" )
82
89
public <T , ID extends Serializable > EntityInformation <T , ID > getEntityInformation (Class <T > domainClass ) {
83
90
84
- RedisPersistentEntity <T > entity = (RedisPersistentEntity <T >) getMappingContext ().getPersistentEntity (domainClass );
91
+ RedisPersistentEntity <T > entity = (RedisPersistentEntity <T >) operations .getMappingContext ()
92
+ .getPersistentEntity (domainClass );
85
93
EntityInformation <T , ID > entityInformation = (EntityInformation <T , ID >) new MappingRedisEntityInformation <T , ID >(
86
94
entity );
87
95
0 commit comments