@@ -272,15 +272,6 @@ protected <T> DefaultTypedExecuteSpec<T> createTypedExecuteSpec(Map<Integer, Set
272272 return new DefaultTypedExecuteSpec <>(byIndex , byName , sqlSupplier , filterFunction , typeToRead );
273273 }
274274
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-
284275 /**
285276 * Customization hook.
286277 */
@@ -354,7 +345,7 @@ <T> FetchSpec<T> exchange(Supplier<String> sqlSupplier, BiFunction<Row, RowMetad
354345
355346 String sql = getRequiredSql (sqlSupplier );
356347
357- Function <Connection , Statement > executeFunction = it -> {
348+ Function <Connection , Statement > statementFactory = it -> {
358349
359350 if (logger .isDebugEnabled ()) {
360351 logger .debug ("Executing SQL statement [" + sql + "]" );
@@ -412,7 +403,7 @@ <T> FetchSpec<T> exchange(Supplier<String> sqlSupplier, BiFunction<Row, RowMetad
412403 return statement ;
413404 };
414405
415- Function <Connection , Flux <Result >> resultFunction = toFunction (sql , filterFunction , executeFunction );
406+ Function <Connection , Flux <Result >> resultFunction = toFunction (sql , filterFunction , statementFactory );
416407
417408 return new DefaultSqlResult <>(DefaultDatabaseClient .this , //
418409 sql , //
@@ -582,7 +573,7 @@ protected ExecuteSpecSupport createInstance(Map<Integer, SettableValue> byIndex,
582573 @ SuppressWarnings ("unchecked" )
583574 protected class DefaultTypedExecuteSpec <T > extends ExecuteSpecSupport implements TypedExecuteSpec <T > {
584575
585- private final @ Nullable Class <T > typeToRead ;
576+ private final Class <T > typeToRead ;
586577 private final BiFunction <Row , RowMetadata , T > mappingFunction ;
587578
588579 DefaultTypedExecuteSpec (Map <Integer , SettableValue > byIndex , Map <String , SettableValue > byName ,
@@ -600,16 +591,6 @@ protected class DefaultTypedExecuteSpec<T> extends ExecuteSpecSupport implements
600591 }
601592 }
602593
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-
613594 @ Override
614595 public <R > TypedExecuteSpec <R > as (Class <R > resultType ) {
615596
@@ -717,8 +698,8 @@ private abstract class DefaultSelectSpecSupport {
717698 this .page = Pageable .unpaged ();
718699 }
719700
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 ) {
722703 this .table = table ;
723704 this .projectedFields = projectedFields ;
724705 this .criteria = criteria ;
@@ -772,13 +753,13 @@ <R> FetchSpec<R> execute(PreparedOperation<?> preparedOperation, BiFunction<Row,
772753 }
773754
774755 protected abstract DefaultSelectSpecSupport createInstance (SqlIdentifier table , List <SqlIdentifier > projectedFields ,
775- Criteria criteria , Sort sort , Pageable page );
756+ @ Nullable Criteria criteria , Sort sort , Pageable page );
776757 }
777758
778759 private class DefaultGenericSelectSpec extends DefaultSelectSpecSupport implements GenericSelectSpec {
779760
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 ) {
782763 super (table , projectedFields , criteria , sort , page );
783764 }
784765
@@ -861,7 +842,7 @@ private <R> FetchSpec<R> exchange(BiFunction<Row, RowMetadata, R> mappingFunctio
861842
862843 @ Override
863844 protected DefaultGenericSelectSpec createInstance (SqlIdentifier table , List <SqlIdentifier > projectedFields ,
864- Criteria criteria , Sort sort , Pageable page ) {
845+ @ Nullable Criteria criteria , Sort sort , Pageable page ) {
865846 return new DefaultGenericSelectSpec (table , projectedFields , criteria , sort , page );
866847 }
867848 }
@@ -883,8 +864,8 @@ private class DefaultTypedSelectSpec<T> extends DefaultSelectSpecSupport impleme
883864 this .mappingFunction = dataAccessStrategy .getRowMapper (typeToRead );
884865 }
885866
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 ) {
888869
889870 super (table , projectedFields , criteria , sort , page );
890871
@@ -975,7 +956,7 @@ private <R> FetchSpec<R> exchange(BiFunction<Row, RowMetadata, R> mappingFunctio
975956
976957 @ Override
977958 protected DefaultTypedSelectSpec <T > createInstance (SqlIdentifier table , List <SqlIdentifier > projectedFields ,
978- Criteria criteria , Sort sort , Pageable page ) {
959+ @ Nullable Criteria criteria , Sort sort , Pageable page ) {
979960 return new DefaultTypedSelectSpec <>(table , projectedFields , criteria , sort , page , this .typeToRead ,
980961 this .mappingFunction );
981962 }
@@ -1223,11 +1204,11 @@ class DefaultGenericUpdateSpec implements GenericUpdateSpec, UpdateMatchingSpec
12231204
12241205 private final @ Nullable Class <?> typeToUpdate ;
12251206 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 ;
12281209
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 ) {
12311212 this .typeToUpdate = typeToUpdate ;
12321213 this .table = table ;
12331214 this .assignments = assignments ;
@@ -1256,6 +1237,7 @@ public UpdatedRowsFetchSpec fetch() {
12561237 SqlIdentifier table ;
12571238
12581239 if (StringUtils .isEmpty (this .table )) {
1240+ Assert .state (this .typeToUpdate != null , "Type to update must not be null!" );
12591241 table = dataAccessStrategy .getTableName (this .typeToUpdate );
12601242 } else {
12611243 table = this .table ;
@@ -1277,6 +1259,7 @@ private UpdatedRowsFetchSpec exchange(SqlIdentifier table) {
12771259 mapper = mapper .forType (this .typeToUpdate );
12781260 }
12791261
1262+ Assert .state (this .assignments != null , "Update assignments must not be null!" );
12801263 StatementMapper .UpdateSpec update = mapper .createUpdate (table , this .assignments );
12811264
12821265 if (this .where != null ) {
@@ -1291,11 +1274,11 @@ private UpdatedRowsFetchSpec exchange(SqlIdentifier table) {
12911274
12921275 class DefaultTypedUpdateSpec <T > implements TypedUpdateSpec <T >, UpdateSpec {
12931276
1294- private final @ Nullable Class <T > typeToUpdate ;
1277+ private final Class <T > typeToUpdate ;
12951278 private final @ Nullable SqlIdentifier table ;
1296- private final T objectToUpdate ;
1279+ private final @ Nullable T objectToUpdate ;
12971280
1298- DefaultTypedUpdateSpec (@ Nullable Class <T > typeToUpdate , @ Nullable SqlIdentifier table , T objectToUpdate ) {
1281+ DefaultTypedUpdateSpec (Class <T > typeToUpdate , @ Nullable SqlIdentifier table , @ Nullable T objectToUpdate ) {
12991282 this .typeToUpdate = typeToUpdate ;
13001283 this .table = table ;
13011284 this .objectToUpdate = objectToUpdate ;
@@ -1390,9 +1373,9 @@ class DefaultDeleteSpec<T> implements DeleteMatchingSpec, TypedDeleteSpec<T> {
13901373
13911374 private final @ Nullable Class <T > typeToDelete ;
13921375 private final @ Nullable SqlIdentifier table ;
1393- private final Criteria where ;
1376+ private final @ Nullable Criteria where ;
13941377
1395- DefaultDeleteSpec (@ Nullable Class <T > typeToDelete , @ Nullable SqlIdentifier table , Criteria where ) {
1378+ DefaultDeleteSpec (@ Nullable Class <T > typeToDelete , @ Nullable SqlIdentifier table , @ Nullable Criteria where ) {
13961379 this .typeToDelete = typeToDelete ;
13971380 this .table = table ;
13981381 this .where = where ;
@@ -1420,6 +1403,7 @@ public UpdatedRowsFetchSpec fetch() {
14201403 SqlIdentifier table ;
14211404
14221405 if (StringUtils .isEmpty (this .table )) {
1406+ Assert .state (this .typeToDelete != null , "Type to delete must not be null!" );
14231407 table = dataAccessStrategy .getTableName (this .typeToDelete );
14241408 } else {
14251409 table = this .table ;
@@ -1608,9 +1592,7 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
16081592
16091593 // Invoke method on target Connection.
16101594 try {
1611- Object retVal = method .invoke (this .target , args );
1612-
1613- return retVal ;
1595+ return method .invoke (this .target , args );
16141596 } catch (InvocationTargetException ex ) {
16151597 throw ex .getTargetException ();
16161598 }
0 commit comments