39
39
import org .springframework .data .repository .core .RepositoryMetadata ;
40
40
import org .springframework .data .repository .core .support .RepositoryComposition .RepositoryFragments ;
41
41
import org .springframework .data .repository .core .support .RepositoryFactorySupport ;
42
- import org .springframework .data .repository .core .support .RepositoryFragment ;
43
42
import org .springframework .data .repository .query .QueryLookupStrategy ;
44
43
import org .springframework .data .repository .query .QueryLookupStrategy .Key ;
45
44
import org .springframework .data .repository .query .QueryMethodEvaluationContextProvider ;
@@ -92,8 +91,21 @@ protected Class<?> getRepositoryBaseClass(RepositoryMetadata metadata) {
92
91
*/
93
92
@ Override
94
93
protected RepositoryFragments getRepositoryFragments (RepositoryMetadata metadata ) {
94
+ return getRepositoryFragments (metadata , operations );
95
+ }
95
96
96
- RepositoryFragments fragments = RepositoryFragments .empty ();
97
+ /**
98
+ * Creates {@link RepositoryFragments} based on {@link RepositoryMetadata} to add Mongo-specific extensions. Typically
99
+ * adds a {@link QuerydslMongoPredicateExecutor} if the repository interface uses Querydsl.
100
+ * <p>
101
+ * Can be overridden by subclasses to customize {@link RepositoryFragments}.
102
+ *
103
+ * @param metadata repository metadata.
104
+ * @param operations the MongoDB operations manager.
105
+ * @return
106
+ * @since 3.2.1
107
+ */
108
+ protected RepositoryFragments getRepositoryFragments (RepositoryMetadata metadata , MongoOperations operations ) {
97
109
98
110
boolean isQueryDslRepository = QUERY_DSL_PRESENT
99
111
&& QuerydslPredicateExecutor .class .isAssignableFrom (metadata .getRepositoryInterface ());
@@ -105,14 +117,11 @@ protected RepositoryFragments getRepositoryFragments(RepositoryMetadata metadata
105
117
"Cannot combine Querydsl and reactive repository support in a single interface" );
106
118
}
107
119
108
- MongoEntityInformation <?, Serializable > entityInformation = getEntityInformation (metadata .getDomainType (),
109
- metadata );
110
-
111
- fragments = fragments .append (RepositoryFragment .implemented (
112
- getTargetRepositoryViaReflection (QuerydslMongoPredicateExecutor .class , entityInformation , operations )));
120
+ return RepositoryFragments
121
+ .just (new QuerydslMongoPredicateExecutor <>(getEntityInformation (metadata .getDomainType ()), operations ));
113
122
}
114
123
115
- return fragments ;
124
+ return RepositoryFragments . empty () ;
116
125
}
117
126
118
127
/*
0 commit comments