@@ -66,10 +66,9 @@ abstract class JdbcQueryLookupStrategy extends RelationalQueryLookupStrategy {
66
66
private static final Log LOG = LogFactory .getLog (JdbcQueryLookupStrategy .class );
67
67
68
68
private final ApplicationEventPublisher publisher ;
69
- private final @ Nullable EntityCallbacks callbacks ;
70
69
private final RelationalMappingContext context ;
70
+ private final @ Nullable EntityCallbacks callbacks ;
71
71
private final JdbcConverter converter ;
72
- private final Dialect dialect ;
73
72
private final QueryMappingConfiguration queryMappingConfiguration ;
74
73
private final NamedParameterJdbcOperations operations ;
75
74
@ Nullable private final BeanFactory beanfactory ;
@@ -83,24 +82,25 @@ abstract class JdbcQueryLookupStrategy extends RelationalQueryLookupStrategy {
83
82
super (context , dialect );
84
83
85
84
Assert .notNull (publisher , "ApplicationEventPublisher must not be null" );
86
- Assert .notNull (context , "RelationalMappingContext must not be null" );
87
85
Assert .notNull (converter , "JdbcConverter must not be null" );
88
- Assert .notNull (dialect , "Dialect must not be null" );
89
86
Assert .notNull (queryMappingConfiguration , "QueryMappingConfiguration must not be null" );
90
87
Assert .notNull (operations , "NamedParameterJdbcOperations must not be null" );
91
88
Assert .notNull (evaluationContextProvider , "QueryMethodEvaluationContextProvier must not be null" );
92
89
90
+ this .context = context ;
93
91
this .publisher = publisher ;
94
92
this .callbacks = callbacks ;
95
- this .context = context ;
96
93
this .converter = converter ;
97
- this .dialect = dialect ;
98
94
this .queryMappingConfiguration = queryMappingConfiguration ;
99
95
this .operations = operations ;
100
96
this .beanfactory = beanfactory ;
101
97
this .evaluationContextProvider = evaluationContextProvider ;
102
98
}
103
99
100
+ public RelationalMappingContext getMappingContext () {
101
+ return context ;
102
+ }
103
+
104
104
/**
105
105
* {@link QueryLookupStrategy} to create a query from the method name.
106
106
*
@@ -124,7 +124,7 @@ public RepositoryQuery resolveQuery(Method method, RepositoryMetadata repository
124
124
125
125
JdbcQueryMethod queryMethod = getJdbcQueryMethod (method , repositoryMetadata , projectionFactory , namedQueries );
126
126
127
- return new PartTreeJdbcQuery (getContext (), queryMethod , getDialect (), getConverter (), getOperations (),
127
+ return new PartTreeJdbcQuery (getMappingContext (), queryMethod , getDialect (), getConverter (), getOperations (),
128
128
this ::createMapper );
129
129
}
130
130
}
@@ -161,8 +161,8 @@ public RepositoryQuery resolveQuery(Method method, RepositoryMetadata repository
161
161
162
162
String queryString = evaluateTableExpressions (repositoryMetadata , queryMethod .getRequiredQuery ());
163
163
164
- StringBasedJdbcQuery query = new StringBasedJdbcQuery (queryMethod , getOperations (), this :: createMapper ,
165
- getConverter (), evaluationContextProvider , queryString );
164
+ StringBasedJdbcQuery query = new StringBasedJdbcQuery (queryString , queryMethod , getOperations (),
165
+ this :: createMapper , getConverter (), evaluationContextProvider );
166
166
query .setBeanFactory (getBeanFactory ());
167
167
return query ;
168
168
}
@@ -224,7 +224,7 @@ public RepositoryQuery resolveQuery(Method method, RepositoryMetadata repository
224
224
*/
225
225
JdbcQueryMethod getJdbcQueryMethod (Method method , RepositoryMetadata repositoryMetadata ,
226
226
ProjectionFactory projectionFactory , NamedQueries namedQueries ) {
227
- return new JdbcQueryMethod (method , repositoryMetadata , projectionFactory , namedQueries , context );
227
+ return new JdbcQueryMethod (method , repositoryMetadata , projectionFactory , namedQueries , getMappingContext () );
228
228
}
229
229
230
230
/**
@@ -277,18 +277,10 @@ public static QueryLookupStrategy create(@Nullable Key key, ApplicationEventPubl
277
277
}
278
278
}
279
279
280
- RelationalMappingContext getContext () {
281
- return context ;
282
- }
283
-
284
280
JdbcConverter getConverter () {
285
281
return converter ;
286
282
}
287
283
288
- Dialect getDialect () {
289
- return dialect ;
290
- }
291
-
292
284
NamedParameterJdbcOperations getOperations () {
293
285
return operations ;
294
286
}
@@ -301,7 +293,7 @@ BeanFactory getBeanFactory() {
301
293
@ SuppressWarnings ("unchecked" )
302
294
RowMapper <Object > createMapper (Class <?> returnedObjectType ) {
303
295
304
- RelationalPersistentEntity <?> persistentEntity = context .getPersistentEntity (returnedObjectType );
296
+ RelationalPersistentEntity <?> persistentEntity = getMappingContext () .getPersistentEntity (returnedObjectType );
305
297
306
298
if (persistentEntity == null ) {
307
299
return (RowMapper <Object >) SingleColumnRowMapper .newInstance (returnedObjectType ,
@@ -319,7 +311,7 @@ private RowMapper<?> determineDefaultMapper(Class<?> returnedObjectType) {
319
311
return configuredQueryMapper ;
320
312
321
313
EntityRowMapper <?> defaultEntityRowMapper = new EntityRowMapper <>( //
322
- context .getRequiredPersistentEntity (returnedObjectType ), //
314
+ getMappingContext () .getRequiredPersistentEntity (returnedObjectType ), //
323
315
converter //
324
316
);
325
317
0 commit comments