@@ -216,6 +216,29 @@ protected DataAccessException translateException(String task, @Nullable String s
216
216
return (dae != null ? dae : new UncategorizedR2dbcException (task , sql , ex ));
217
217
}
218
218
219
+ /**
220
+ * Customization hook.
221
+ */
222
+ protected <T > DefaultTypedExecuteSpec <T > createTypedExecuteSpec (Map <Integer , SettableValue > byIndex ,
223
+ Map <String , SettableValue > byName , Supplier <String > sqlSupplier , Class <T > typeToRead ) {
224
+ return new DefaultTypedExecuteSpec <>(byIndex , byName , sqlSupplier , typeToRead );
225
+ }
226
+
227
+ /**
228
+ * Customization hook.
229
+ */
230
+ protected ExecuteSpecSupport createGenericExecuteSpec (Map <Integer , SettableValue > byIndex ,
231
+ Map <String , SettableValue > byName , Supplier <String > sqlSupplier ) {
232
+ return new DefaultGenericExecuteSpec (byIndex , byName , sqlSupplier );
233
+ }
234
+
235
+ /**
236
+ * Customization hook.
237
+ */
238
+ protected DefaultGenericExecuteSpec createGenericExecuteSpec (Supplier <String > sqlSupplier ) {
239
+ return new DefaultGenericExecuteSpec (sqlSupplier );
240
+ }
241
+
219
242
private static void doBind (Statement statement , Map <String , SettableValue > byName ,
220
243
Map <Integer , SettableValue > byIndex ) {
221
244
@@ -236,7 +259,6 @@ private static void doBind(Statement statement, Map<String, SettableValue> byNam
236
259
statement .bindNull (name , o .getType ());
237
260
}
238
261
});
239
-
240
262
}
241
263
242
264
/**
@@ -256,21 +278,21 @@ public GenericExecuteSpec sql(Supplier<String> sqlSupplier) {
256
278
257
279
Assert .notNull (sqlSupplier , "SQL Supplier must not be null!" );
258
280
259
- return new DefaultGenericExecuteSpec (sqlSupplier );
281
+ return createGenericExecuteSpec (sqlSupplier );
260
282
}
261
283
}
262
284
263
285
/**
264
286
* Base class for {@link DatabaseClient.GenericExecuteSpec} implementations.
265
287
*/
266
288
@ RequiredArgsConstructor
267
- private class GenericExecuteSpecSupport {
289
+ class ExecuteSpecSupport {
268
290
269
291
final Map <Integer , SettableValue > byIndex ;
270
292
final Map <String , SettableValue > byName ;
271
293
final Supplier <String > sqlSupplier ;
272
294
273
- GenericExecuteSpecSupport (Supplier <String > sqlSupplier ) {
295
+ ExecuteSpecSupport (Supplier <String > sqlSupplier ) {
274
296
275
297
this .byIndex = Collections .emptyMap ();
276
298
this .byName = Collections .emptyMap ();
@@ -284,7 +306,7 @@ protected String getSql() {
284
306
return sql ;
285
307
}
286
308
287
- protected <T > SqlResult <T > exchange (String sql , BiFunction <Row , RowMetadata , T > mappingFunction ) {
309
+ <T > SqlResult <T > exchange (String sql , BiFunction <Row , RowMetadata , T > mappingFunction ) {
288
310
289
311
Function <Connection , Statement > executeFunction = it -> {
290
312
@@ -307,23 +329,23 @@ protected <T> SqlResult<T> exchange(String sql, BiFunction<Row, RowMetadata, T>
307
329
mappingFunction );
308
330
}
309
331
310
- public GenericExecuteSpecSupport bind (int index , Object value ) {
332
+ public ExecuteSpecSupport bind (int index , Object value ) {
311
333
312
334
Map <Integer , SettableValue > byIndex = new LinkedHashMap <>(this .byIndex );
313
335
byIndex .put (index , new SettableValue (index , value , null ));
314
336
315
337
return createInstance (byIndex , this .byName , this .sqlSupplier );
316
338
}
317
339
318
- public GenericExecuteSpecSupport bindNull (int index , Class <?> type ) {
340
+ public ExecuteSpecSupport bindNull (int index , Class <?> type ) {
319
341
320
342
Map <Integer , SettableValue > byIndex = new LinkedHashMap <>(this .byIndex );
321
343
byIndex .put (index , new SettableValue (index , null , type ));
322
344
323
345
return createInstance (byIndex , this .byName , this .sqlSupplier );
324
346
}
325
347
326
- public GenericExecuteSpecSupport bind (String name , Object value ) {
348
+ public ExecuteSpecSupport bind (String name , Object value ) {
327
349
328
350
Assert .hasText (name , "Parameter name must not be null or empty!" );
329
351
@@ -333,7 +355,7 @@ public GenericExecuteSpecSupport bind(String name, Object value) {
333
355
return createInstance (this .byIndex , byName , this .sqlSupplier );
334
356
}
335
357
336
- public GenericExecuteSpecSupport bindNull (String name , Class <?> type ) {
358
+ public ExecuteSpecSupport bindNull (String name , Class <?> type ) {
337
359
338
360
Assert .hasText (name , "Parameter name must not be null or empty!" );
339
361
@@ -343,12 +365,12 @@ public GenericExecuteSpecSupport bindNull(String name, Class<?> type) {
343
365
return createInstance (this .byIndex , byName , this .sqlSupplier );
344
366
}
345
367
346
- protected GenericExecuteSpecSupport createInstance (Map <Integer , SettableValue > byIndex ,
347
- Map < String , SettableValue > byName , Supplier <String > sqlSupplier ) {
348
- return new GenericExecuteSpecSupport (byIndex , byName , sqlSupplier );
368
+ protected ExecuteSpecSupport createInstance (Map <Integer , SettableValue > byIndex , Map < String , SettableValue > byName ,
369
+ Supplier <String > sqlSupplier ) {
370
+ return new ExecuteSpecSupport (byIndex , byName , sqlSupplier );
349
371
}
350
372
351
- public GenericExecuteSpecSupport bind (Object bean ) {
373
+ public ExecuteSpecSupport bind (Object bean ) {
352
374
353
375
Assert .notNull (bean , "Bean must not be null!" );
354
376
@@ -359,7 +381,7 @@ public GenericExecuteSpecSupport bind(Object bean) {
359
381
/**
360
382
* Default {@link DatabaseClient.GenericExecuteSpec} implementation.
361
383
*/
362
- private class DefaultGenericExecuteSpec extends GenericExecuteSpecSupport implements GenericExecuteSpec {
384
+ protected class DefaultGenericExecuteSpec extends ExecuteSpecSupport implements GenericExecuteSpec {
363
385
364
386
DefaultGenericExecuteSpec (Map <Integer , SettableValue > byIndex , Map <String , SettableValue > byName ,
365
387
Supplier <String > sqlSupplier ) {
@@ -375,7 +397,7 @@ public <R> TypedExecuteSpec<R> as(Class<R> resultType) {
375
397
376
398
Assert .notNull (resultType , "Result type must not be null!" );
377
399
378
- return new DefaultTypedGenericExecuteSpec <> (this .byIndex , this .byName , this .sqlSupplier , resultType );
400
+ return createTypedExecuteSpec (this .byIndex , this .byName , this .sqlSupplier , resultType );
379
401
}
380
402
381
403
@ Override
@@ -414,22 +436,22 @@ public DefaultGenericExecuteSpec bind(Object bean) {
414
436
}
415
437
416
438
@ Override
417
- protected GenericExecuteSpecSupport createInstance (Map <Integer , SettableValue > byIndex ,
418
- Map < String , SettableValue > byName , Supplier <String > sqlSupplier ) {
419
- return new DefaultGenericExecuteSpec (byIndex , byName , sqlSupplier );
439
+ protected ExecuteSpecSupport createInstance (Map <Integer , SettableValue > byIndex , Map < String , SettableValue > byName ,
440
+ Supplier <String > sqlSupplier ) {
441
+ return createGenericExecuteSpec (byIndex , byName , sqlSupplier );
420
442
}
421
443
}
422
444
423
445
/**
424
446
* Default {@link DatabaseClient.GenericExecuteSpec} implementation.
425
447
*/
426
448
@ SuppressWarnings ("unchecked" )
427
- private class DefaultTypedGenericExecuteSpec <T > extends GenericExecuteSpecSupport implements TypedExecuteSpec <T > {
449
+ protected class DefaultTypedExecuteSpec <T > extends ExecuteSpecSupport implements TypedExecuteSpec <T > {
428
450
429
451
private final Class <T > typeToRead ;
430
452
private final BiFunction <Row , RowMetadata , T > mappingFunction ;
431
453
432
- DefaultTypedGenericExecuteSpec (Map <Integer , SettableValue > byIndex , Map <String , SettableValue > byName ,
454
+ DefaultTypedExecuteSpec (Map <Integer , SettableValue > byIndex , Map <String , SettableValue > byName ,
433
455
Supplier <String > sqlSupplier , Class <T > typeToRead ) {
434
456
435
457
super (byIndex , byName , sqlSupplier );
@@ -443,7 +465,7 @@ public <R> TypedExecuteSpec<R> as(Class<R> resultType) {
443
465
444
466
Assert .notNull (resultType , "Result type must not be null!" );
445
467
446
- return new DefaultTypedGenericExecuteSpec <> (this .byIndex , this .byName , this .sqlSupplier , resultType );
468
+ return createTypedExecuteSpec (this .byIndex , this .byName , this .sqlSupplier , resultType );
447
469
}
448
470
449
471
@ Override
@@ -457,34 +479,34 @@ public Mono<SqlResult<T>> exchange() {
457
479
}
458
480
459
481
@ Override
460
- public DefaultTypedGenericExecuteSpec <T > bind (int index , Object value ) {
461
- return (DefaultTypedGenericExecuteSpec <T >) super .bind (index , value );
482
+ public DefaultTypedExecuteSpec <T > bind (int index , Object value ) {
483
+ return (DefaultTypedExecuteSpec <T >) super .bind (index , value );
462
484
}
463
485
464
486
@ Override
465
- public DefaultTypedGenericExecuteSpec <T > bindNull (int index , Class <?> type ) {
466
- return (DefaultTypedGenericExecuteSpec <T >) super .bindNull (index , type );
487
+ public DefaultTypedExecuteSpec <T > bindNull (int index , Class <?> type ) {
488
+ return (DefaultTypedExecuteSpec <T >) super .bindNull (index , type );
467
489
}
468
490
469
491
@ Override
470
- public DefaultTypedGenericExecuteSpec <T > bind (String name , Object value ) {
471
- return (DefaultTypedGenericExecuteSpec ) super .bind (name , value );
492
+ public DefaultTypedExecuteSpec <T > bind (String name , Object value ) {
493
+ return (DefaultTypedExecuteSpec ) super .bind (name , value );
472
494
}
473
495
474
496
@ Override
475
- public DefaultTypedGenericExecuteSpec <T > bindNull (String name , Class <?> type ) {
476
- return (DefaultTypedGenericExecuteSpec <T >) super .bindNull (name , type );
497
+ public DefaultTypedExecuteSpec <T > bindNull (String name , Class <?> type ) {
498
+ return (DefaultTypedExecuteSpec <T >) super .bindNull (name , type );
477
499
}
478
500
479
501
@ Override
480
- public DefaultTypedGenericExecuteSpec <T > bind (Object bean ) {
481
- return (DefaultTypedGenericExecuteSpec <T >) super .bind (bean );
502
+ public DefaultTypedExecuteSpec <T > bind (Object bean ) {
503
+ return (DefaultTypedExecuteSpec <T >) super .bind (bean );
482
504
}
483
505
484
506
@ Override
485
- protected DefaultTypedGenericExecuteSpec <T > createInstance (Map <Integer , SettableValue > byIndex ,
507
+ protected DefaultTypedExecuteSpec <T > createInstance (Map <Integer , SettableValue > byIndex ,
486
508
Map <String , SettableValue > byName , Supplier <String > sqlSupplier ) {
487
- return new DefaultTypedGenericExecuteSpec <> (byIndex , byName , sqlSupplier , typeToRead );
509
+ return createTypedExecuteSpec (byIndex , byName , sqlSupplier , typeToRead );
488
510
}
489
511
}
490
512
@@ -550,8 +572,8 @@ public DefaultSelectSpecSupport page(Pageable page) {
550
572
}
551
573
552
574
StringBuilder getLimitOffset (Pageable pageable ) {
553
- return new StringBuilder ().append ("LIMIT" ).append (' ' ).append (page .getPageSize ()) //
554
- .append (' ' ).append ("OFFSET" ).append (' ' ).append (page .getOffset ());
575
+ return new StringBuilder ().append ("LIMIT" ).append (' ' ).append (pageable .getPageSize ()) //
576
+ .append (' ' ).append ("OFFSET" ).append (' ' ).append (pageable .getOffset ());
555
577
}
556
578
557
579
StringBuilder getSortClause (Sort sort ) {
0 commit comments