@@ -272,15 +272,6 @@ protected <T> DefaultTypedExecuteSpec<T> createTypedExecuteSpec(Map<Integer, Set
272
272
return new DefaultTypedExecuteSpec <>(byIndex , byName , sqlSupplier , filterFunction , typeToRead );
273
273
}
274
274
275
- /**
276
- * Customization hook.
277
- */
278
- protected <T > DefaultTypedExecuteSpec <T > createTypedExecuteSpec (Map <Integer , SettableValue > byIndex ,
279
- Map <String , SettableValue > byName , Supplier <String > sqlSupplier , StatementFilterFunction filterFunction ,
280
- BiFunction <Row , RowMetadata , T > mappingFunction ) {
281
- return new DefaultTypedExecuteSpec <>(byIndex , byName , sqlSupplier , filterFunction , mappingFunction );
282
- }
283
-
284
275
/**
285
276
* Customization hook.
286
277
*/
@@ -354,7 +345,7 @@ <T> FetchSpec<T> exchange(Supplier<String> sqlSupplier, BiFunction<Row, RowMetad
354
345
355
346
String sql = getRequiredSql (sqlSupplier );
356
347
357
- Function <Connection , Statement > executeFunction = it -> {
348
+ Function <Connection , Statement > statementFactory = it -> {
358
349
359
350
if (logger .isDebugEnabled ()) {
360
351
logger .debug ("Executing SQL statement [" + sql + "]" );
@@ -412,7 +403,7 @@ <T> FetchSpec<T> exchange(Supplier<String> sqlSupplier, BiFunction<Row, RowMetad
412
403
return statement ;
413
404
};
414
405
415
- Function <Connection , Flux <Result >> resultFunction = toFunction (sql , filterFunction , executeFunction );
406
+ Function <Connection , Flux <Result >> resultFunction = toFunction (sql , filterFunction , statementFactory );
416
407
417
408
return new DefaultSqlResult <>(DefaultDatabaseClient .this , //
418
409
sql , //
@@ -582,7 +573,7 @@ protected ExecuteSpecSupport createInstance(Map<Integer, SettableValue> byIndex,
582
573
@ SuppressWarnings ("unchecked" )
583
574
protected class DefaultTypedExecuteSpec <T > extends ExecuteSpecSupport implements TypedExecuteSpec <T > {
584
575
585
- private final @ Nullable Class <T > typeToRead ;
576
+ private final Class <T > typeToRead ;
586
577
private final BiFunction <Row , RowMetadata , T > mappingFunction ;
587
578
588
579
DefaultTypedExecuteSpec (Map <Integer , SettableValue > byIndex , Map <String , SettableValue > byName ,
@@ -600,16 +591,6 @@ protected class DefaultTypedExecuteSpec<T> extends ExecuteSpecSupport implements
600
591
}
601
592
}
602
593
603
- DefaultTypedExecuteSpec (Map <Integer , SettableValue > byIndex , Map <String , SettableValue > byName ,
604
- Supplier <String > sqlSupplier , StatementFilterFunction filterFunction ,
605
- BiFunction <Row , RowMetadata , T > mappingFunction ) {
606
-
607
- super (byIndex , byName , sqlSupplier , filterFunction );
608
-
609
- this .typeToRead = null ;
610
- this .mappingFunction = mappingFunction ;
611
- }
612
-
613
594
@ Override
614
595
public <R > TypedExecuteSpec <R > as (Class <R > resultType ) {
615
596
@@ -717,8 +698,8 @@ private abstract class DefaultSelectSpecSupport {
717
698
this .page = Pageable .unpaged ();
718
699
}
719
700
720
- DefaultSelectSpecSupport (SqlIdentifier table , List <SqlIdentifier > projectedFields , Criteria criteria , Sort sort ,
721
- Pageable page ) {
701
+ DefaultSelectSpecSupport (SqlIdentifier table , List <SqlIdentifier > projectedFields , @ Nullable Criteria criteria ,
702
+ Sort sort , Pageable page ) {
722
703
this .table = table ;
723
704
this .projectedFields = projectedFields ;
724
705
this .criteria = criteria ;
@@ -772,13 +753,13 @@ <R> FetchSpec<R> execute(PreparedOperation<?> preparedOperation, BiFunction<Row,
772
753
}
773
754
774
755
protected abstract DefaultSelectSpecSupport createInstance (SqlIdentifier table , List <SqlIdentifier > projectedFields ,
775
- Criteria criteria , Sort sort , Pageable page );
756
+ @ Nullable Criteria criteria , Sort sort , Pageable page );
776
757
}
777
758
778
759
private class DefaultGenericSelectSpec extends DefaultSelectSpecSupport implements GenericSelectSpec {
779
760
780
- DefaultGenericSelectSpec (SqlIdentifier table , List <SqlIdentifier > projectedFields , Criteria criteria , Sort sort ,
781
- Pageable page ) {
761
+ DefaultGenericSelectSpec (SqlIdentifier table , List <SqlIdentifier > projectedFields , @ Nullable Criteria criteria ,
762
+ Sort sort , Pageable page ) {
782
763
super (table , projectedFields , criteria , sort , page );
783
764
}
784
765
@@ -861,7 +842,7 @@ private <R> FetchSpec<R> exchange(BiFunction<Row, RowMetadata, R> mappingFunctio
861
842
862
843
@ Override
863
844
protected DefaultGenericSelectSpec createInstance (SqlIdentifier table , List <SqlIdentifier > projectedFields ,
864
- Criteria criteria , Sort sort , Pageable page ) {
845
+ @ Nullable Criteria criteria , Sort sort , Pageable page ) {
865
846
return new DefaultGenericSelectSpec (table , projectedFields , criteria , sort , page );
866
847
}
867
848
}
@@ -883,8 +864,8 @@ private class DefaultTypedSelectSpec<T> extends DefaultSelectSpecSupport impleme
883
864
this .mappingFunction = dataAccessStrategy .getRowMapper (typeToRead );
884
865
}
885
866
886
- DefaultTypedSelectSpec (SqlIdentifier table , List <SqlIdentifier > projectedFields , Criteria criteria , Sort sort ,
887
- Pageable page , @ Nullable Class <T > typeToRead , BiFunction <Row , RowMetadata , T > mappingFunction ) {
867
+ DefaultTypedSelectSpec (SqlIdentifier table , List <SqlIdentifier > projectedFields , @ Nullable Criteria criteria ,
868
+ Sort sort , Pageable page , Class <T > typeToRead , BiFunction <Row , RowMetadata , T > mappingFunction ) {
888
869
889
870
super (table , projectedFields , criteria , sort , page );
890
871
@@ -975,7 +956,7 @@ private <R> FetchSpec<R> exchange(BiFunction<Row, RowMetadata, R> mappingFunctio
975
956
976
957
@ Override
977
958
protected DefaultTypedSelectSpec <T > createInstance (SqlIdentifier table , List <SqlIdentifier > projectedFields ,
978
- Criteria criteria , Sort sort , Pageable page ) {
959
+ @ Nullable Criteria criteria , Sort sort , Pageable page ) {
979
960
return new DefaultTypedSelectSpec <>(table , projectedFields , criteria , sort , page , this .typeToRead ,
980
961
this .mappingFunction );
981
962
}
@@ -1223,11 +1204,11 @@ class DefaultGenericUpdateSpec implements GenericUpdateSpec, UpdateMatchingSpec
1223
1204
1224
1205
private final @ Nullable Class <?> typeToUpdate ;
1225
1206
private final @ Nullable SqlIdentifier table ;
1226
- private final Update assignments ;
1227
- private final Criteria where ;
1207
+ private final @ Nullable Update assignments ;
1208
+ private final @ Nullable Criteria where ;
1228
1209
1229
- DefaultGenericUpdateSpec (@ Nullable Class <?> typeToUpdate , @ Nullable SqlIdentifier table , Update assignments ,
1230
- Criteria where ) {
1210
+ DefaultGenericUpdateSpec (@ Nullable Class <?> typeToUpdate , @ Nullable SqlIdentifier table ,
1211
+ @ Nullable Update assignments , @ Nullable Criteria where ) {
1231
1212
this .typeToUpdate = typeToUpdate ;
1232
1213
this .table = table ;
1233
1214
this .assignments = assignments ;
@@ -1256,6 +1237,7 @@ public UpdatedRowsFetchSpec fetch() {
1256
1237
SqlIdentifier table ;
1257
1238
1258
1239
if (StringUtils .isEmpty (this .table )) {
1240
+ Assert .state (this .typeToUpdate != null , "Type to update must not be null!" );
1259
1241
table = dataAccessStrategy .getTableName (this .typeToUpdate );
1260
1242
} else {
1261
1243
table = this .table ;
@@ -1277,6 +1259,7 @@ private UpdatedRowsFetchSpec exchange(SqlIdentifier table) {
1277
1259
mapper = mapper .forType (this .typeToUpdate );
1278
1260
}
1279
1261
1262
+ Assert .state (this .assignments != null , "Update assignments must not be null!" );
1280
1263
StatementMapper .UpdateSpec update = mapper .createUpdate (table , this .assignments );
1281
1264
1282
1265
if (this .where != null ) {
@@ -1291,11 +1274,11 @@ private UpdatedRowsFetchSpec exchange(SqlIdentifier table) {
1291
1274
1292
1275
class DefaultTypedUpdateSpec <T > implements TypedUpdateSpec <T >, UpdateSpec {
1293
1276
1294
- private final @ Nullable Class <T > typeToUpdate ;
1277
+ private final Class <T > typeToUpdate ;
1295
1278
private final @ Nullable SqlIdentifier table ;
1296
- private final T objectToUpdate ;
1279
+ private final @ Nullable T objectToUpdate ;
1297
1280
1298
- DefaultTypedUpdateSpec (@ Nullable Class <T > typeToUpdate , @ Nullable SqlIdentifier table , T objectToUpdate ) {
1281
+ DefaultTypedUpdateSpec (Class <T > typeToUpdate , @ Nullable SqlIdentifier table , @ Nullable T objectToUpdate ) {
1299
1282
this .typeToUpdate = typeToUpdate ;
1300
1283
this .table = table ;
1301
1284
this .objectToUpdate = objectToUpdate ;
@@ -1390,9 +1373,9 @@ class DefaultDeleteSpec<T> implements DeleteMatchingSpec, TypedDeleteSpec<T> {
1390
1373
1391
1374
private final @ Nullable Class <T > typeToDelete ;
1392
1375
private final @ Nullable SqlIdentifier table ;
1393
- private final Criteria where ;
1376
+ private final @ Nullable Criteria where ;
1394
1377
1395
- DefaultDeleteSpec (@ Nullable Class <T > typeToDelete , @ Nullable SqlIdentifier table , Criteria where ) {
1378
+ DefaultDeleteSpec (@ Nullable Class <T > typeToDelete , @ Nullable SqlIdentifier table , @ Nullable Criteria where ) {
1396
1379
this .typeToDelete = typeToDelete ;
1397
1380
this .table = table ;
1398
1381
this .where = where ;
@@ -1420,6 +1403,7 @@ public UpdatedRowsFetchSpec fetch() {
1420
1403
SqlIdentifier table ;
1421
1404
1422
1405
if (StringUtils .isEmpty (this .table )) {
1406
+ Assert .state (this .typeToDelete != null , "Type to delete must not be null!" );
1423
1407
table = dataAccessStrategy .getTableName (this .typeToDelete );
1424
1408
} else {
1425
1409
table = this .table ;
@@ -1608,9 +1592,7 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
1608
1592
1609
1593
// Invoke method on target Connection.
1610
1594
try {
1611
- Object retVal = method .invoke (this .target , args );
1612
-
1613
- return retVal ;
1595
+ return method .invoke (this .target , args );
1614
1596
} catch (InvocationTargetException ex ) {
1615
1597
throw ex .getTargetException ();
1616
1598
}
0 commit comments