26
26
27
27
import org .springframework .dao .InvalidDataAccessResourceUsageException ;
28
28
import org .springframework .data .convert .CustomConversions .StoreConversions ;
29
- import org .springframework .data .domain .Sort ;
30
- import org .springframework .data .domain .Sort .Order ;
31
29
import org .springframework .data .mapping .context .MappingContext ;
32
30
import org .springframework .data .r2dbc .dialect .ArrayColumns ;
33
31
import org .springframework .data .r2dbc .dialect .BindMarkersFactory ;
@@ -62,7 +60,6 @@ public class DefaultReactiveDataAccessStrategy implements ReactiveDataAccessStra
62
60
private final R2dbcConverter converter ;
63
61
private final UpdateMapper updateMapper ;
64
62
private final MappingContext <RelationalPersistentEntity <?>, ? extends RelationalPersistentProperty > mappingContext ;
65
- private final StatementFactory statements ;
66
63
private final StatementMapper statementMapper ;
67
64
68
65
/**
@@ -127,11 +124,10 @@ public SelectRenderContext getSelect() {
127
124
}
128
125
};
129
126
130
- this .statements = new DefaultStatementFactory (this .dialect , renderContext );
131
- this .statementMapper = new DefaultStatementMapper (dialect , renderContext , updateMapper , mappingContext );
127
+ this .statementMapper = new DefaultStatementMapper (dialect , renderContext , this .updateMapper , this .mappingContext );
132
128
}
133
129
134
- /*
130
+ /*
135
131
* (non-Javadoc)
136
132
* @see org.springframework.data.r2dbc.function.ReactiveDataAccessStrategy#getAllColumns(java.lang.Class)
137
133
*/
@@ -152,7 +148,7 @@ public List<String> getAllColumns(Class<?> entityType) {
152
148
return columnNames ;
153
149
}
154
150
155
- /*
151
+ /*
156
152
* (non-Javadoc)
157
153
* @see org.springframework.data.r2dbc.function.ReactiveDataAccessStrategy#getIdentifierColumns(java.lang.Class)
158
154
*/
@@ -182,7 +178,7 @@ public OutboundRow getOutboundRow(Object object) {
182
178
183
179
OutboundRow row = new OutboundRow ();
184
180
185
- converter .write (object , row );
181
+ this . converter .write (object , row );
186
182
187
183
RelationalPersistentEntity <?> entity = getRequiredPersistentEntity (ClassUtils .getUserClass (object ));
188
184
@@ -205,53 +201,25 @@ private boolean shouldConvertArrayValue(RelationalPersistentProperty property, S
205
201
206
202
private SettableValue getArrayValue (SettableValue value , RelationalPersistentProperty property ) {
207
203
208
- ArrayColumns arrayColumns = dialect .getArraySupport ();
204
+ ArrayColumns arrayColumns = this . dialect .getArraySupport ();
209
205
210
206
if (!arrayColumns .isSupported ()) {
211
207
212
208
throw new InvalidDataAccessResourceUsageException (
213
- "Dialect " + dialect .getClass ().getName () + " does not support array columns" );
209
+ "Dialect " + this . dialect .getClass ().getName () + " does not support array columns" );
214
210
}
215
211
216
- return SettableValue .fromOrEmpty (converter .getArrayValue (arrayColumns , property , value .getValue ()),
212
+ return SettableValue .fromOrEmpty (this . converter .getArrayValue (arrayColumns , property , value .getValue ()),
217
213
property .getActualType ());
218
214
}
219
215
220
- /*
221
- * (non-Javadoc)
222
- * @see org.springframework.data.r2dbc.function.ReactiveDataAccessStrategy#getMappedSort(java.lang.Class, org.springframework.data.domain.Sort)
223
- */
224
- @ Override
225
- public Sort getMappedSort (Sort sort , Class <?> typeToRead ) {
226
-
227
- RelationalPersistentEntity <?> entity = getPersistentEntity (typeToRead );
228
- if (entity == null ) {
229
- return sort ;
230
- }
231
-
232
- List <Order > mappedOrder = new ArrayList <>();
233
-
234
- for (Order order : sort ) {
235
-
236
- RelationalPersistentProperty persistentProperty = entity .getPersistentProperty (order .getProperty ());
237
- if (persistentProperty == null ) {
238
- mappedOrder .add (order );
239
- } else {
240
- mappedOrder
241
- .add (Order .by (persistentProperty .getColumnName ()).with (order .getNullHandling ()).with (order .getDirection ()));
242
- }
243
- }
244
-
245
- return Sort .by (mappedOrder );
246
- }
247
-
248
216
/*
249
217
* (non-Javadoc)
250
218
* @see org.springframework.data.r2dbc.function.ReactiveDataAccessStrategy#getRowMapper(java.lang.Class)
251
219
*/
252
220
@ Override
253
221
public <T > BiFunction <Row , RowMetadata , T > getRowMapper (Class <T > typeToRead ) {
254
- return new EntityRowMapper <>(typeToRead , converter );
222
+ return new EntityRowMapper <>(typeToRead , this . converter );
255
223
}
256
224
257
225
/*
@@ -265,13 +233,8 @@ public String getTableName(Class<?> type) {
265
233
266
234
/*
267
235
* (non-Javadoc)
268
- * @see org.springframework.data.r2dbc.function.ReactiveDataAccessStrategy#getStatements ()
236
+ * @see org.springframework.data.r2dbc.function.ReactiveDataAccessStrategy#getStatementMapper ()
269
237
*/
270
- @ Override
271
- public StatementFactory getStatements () {
272
- return this .statements ;
273
- }
274
-
275
238
@ Override
276
239
public StatementMapper getStatementMapper () {
277
240
return this .statementMapper ;
@@ -283,27 +246,27 @@ public StatementMapper getStatementMapper() {
283
246
*/
284
247
@ Override
285
248
public BindMarkersFactory getBindMarkersFactory () {
286
- return dialect .getBindMarkersFactory ();
249
+ return this . dialect .getBindMarkersFactory ();
287
250
}
288
251
289
252
/*
290
253
* (non-Javadoc)
291
254
* @see org.springframework.data.r2dbc.function.ReactiveDataAccessStrategy#getConverter()
292
255
*/
293
256
public R2dbcConverter getConverter () {
294
- return converter ;
257
+ return this . converter ;
295
258
}
296
259
297
260
public MappingContext <RelationalPersistentEntity <?>, ? extends RelationalPersistentProperty > getMappingContext () {
298
- return mappingContext ;
261
+ return this . mappingContext ;
299
262
}
300
263
301
264
private RelationalPersistentEntity <?> getRequiredPersistentEntity (Class <?> typeToRead ) {
302
- return mappingContext .getRequiredPersistentEntity (typeToRead );
265
+ return this . mappingContext .getRequiredPersistentEntity (typeToRead );
303
266
}
304
267
305
268
@ Nullable
306
269
private RelationalPersistentEntity <?> getPersistentEntity (Class <?> typeToRead ) {
307
- return mappingContext .getPersistentEntity (typeToRead );
270
+ return this . mappingContext .getPersistentEntity (typeToRead );
308
271
}
309
272
}
0 commit comments