60
60
import org .springframework .data .r2dbc .query .Criteria ;
61
61
import org .springframework .data .r2dbc .query .Update ;
62
62
import org .springframework .data .r2dbc .support .R2dbcExceptionTranslator ;
63
+ import org .springframework .data .relational .core .query .CriteriaDefinition ;
63
64
import org .springframework .data .relational .core .sql .SqlIdentifier ;
64
65
import org .springframework .lang .Nullable ;
65
66
import org .springframework .util .Assert ;
@@ -683,7 +684,7 @@ private abstract class DefaultSelectSpecSupport {
683
684
684
685
final SqlIdentifier table ;
685
686
final List <SqlIdentifier > projectedFields ;
686
- final @ Nullable Criteria criteria ;
687
+ final @ Nullable CriteriaDefinition criteria ;
687
688
final Sort sort ;
688
689
final Pageable page ;
689
690
@@ -698,7 +699,8 @@ private abstract class DefaultSelectSpecSupport {
698
699
this .page = Pageable .unpaged ();
699
700
}
700
701
701
- DefaultSelectSpecSupport (SqlIdentifier table , List <SqlIdentifier > projectedFields , @ Nullable Criteria criteria ,
702
+ DefaultSelectSpecSupport (SqlIdentifier table , List <SqlIdentifier > projectedFields ,
703
+ @ Nullable CriteriaDefinition criteria ,
702
704
Sort sort , Pageable page ) {
703
705
this .table = table ;
704
706
this .projectedFields = projectedFields ;
@@ -717,7 +719,7 @@ public DefaultSelectSpecSupport project(SqlIdentifier... selectedFields) {
717
719
return createInstance (this .table , projectedFields , this .criteria , this .sort , this .page );
718
720
}
719
721
720
- public DefaultSelectSpecSupport where (Criteria whereCriteria ) {
722
+ public DefaultSelectSpecSupport where (CriteriaDefinition whereCriteria ) {
721
723
722
724
Assert .notNull (whereCriteria , "Criteria must not be null!" );
723
725
@@ -753,12 +755,13 @@ <R> FetchSpec<R> execute(PreparedOperation<?> preparedOperation, BiFunction<Row,
753
755
}
754
756
755
757
protected abstract DefaultSelectSpecSupport createInstance (SqlIdentifier table , List <SqlIdentifier > projectedFields ,
756
- @ Nullable Criteria criteria , Sort sort , Pageable page );
758
+ @ Nullable CriteriaDefinition criteria , Sort sort , Pageable page );
757
759
}
758
760
759
761
private class DefaultGenericSelectSpec extends DefaultSelectSpecSupport implements GenericSelectSpec {
760
762
761
- DefaultGenericSelectSpec (SqlIdentifier table , List <SqlIdentifier > projectedFields , @ Nullable Criteria criteria ,
763
+ DefaultGenericSelectSpec (SqlIdentifier table , List <SqlIdentifier > projectedFields ,
764
+ @ Nullable CriteriaDefinition criteria ,
762
765
Sort sort , Pageable page ) {
763
766
super (table , projectedFields , criteria , sort , page );
764
767
}
@@ -806,7 +809,7 @@ public DefaultGenericSelectSpec project(SqlIdentifier... selectedFields) {
806
809
}
807
810
808
811
@ Override
809
- public DefaultGenericSelectSpec matching (Criteria criteria ) {
812
+ public DefaultGenericSelectSpec matching (CriteriaDefinition criteria ) {
810
813
return (DefaultGenericSelectSpec ) super .where (criteria );
811
814
}
812
815
@@ -842,7 +845,7 @@ private <R> FetchSpec<R> exchange(BiFunction<Row, RowMetadata, R> mappingFunctio
842
845
843
846
@ Override
844
847
protected DefaultGenericSelectSpec createInstance (SqlIdentifier table , List <SqlIdentifier > projectedFields ,
845
- @ Nullable Criteria criteria , Sort sort , Pageable page ) {
848
+ @ Nullable CriteriaDefinition criteria , Sort sort , Pageable page ) {
846
849
return new DefaultGenericSelectSpec (table , projectedFields , criteria , sort , page );
847
850
}
848
851
}
@@ -864,7 +867,8 @@ private class DefaultTypedSelectSpec<T> extends DefaultSelectSpecSupport impleme
864
867
this .mappingFunction = dataAccessStrategy .getRowMapper (typeToRead );
865
868
}
866
869
867
- DefaultTypedSelectSpec (SqlIdentifier table , List <SqlIdentifier > projectedFields , @ Nullable Criteria criteria ,
870
+ DefaultTypedSelectSpec (SqlIdentifier table , List <SqlIdentifier > projectedFields ,
871
+ @ Nullable CriteriaDefinition criteria ,
868
872
Sort sort , Pageable page , Class <T > typeToRead , BiFunction <Row , RowMetadata , T > mappingFunction ) {
869
873
870
874
super (table , projectedFields , criteria , sort , page );
@@ -912,7 +916,7 @@ public DefaultTypedSelectSpec<T> project(SqlIdentifier... selectedFields) {
912
916
}
913
917
914
918
@ Override
915
- public DefaultTypedSelectSpec <T > matching (Criteria criteria ) {
919
+ public DefaultTypedSelectSpec <T > matching (CriteriaDefinition criteria ) {
916
920
return (DefaultTypedSelectSpec <T >) super .where (criteria );
917
921
}
918
922
@@ -956,7 +960,7 @@ private <R> FetchSpec<R> exchange(BiFunction<Row, RowMetadata, R> mappingFunctio
956
960
957
961
@ Override
958
962
protected DefaultTypedSelectSpec <T > createInstance (SqlIdentifier table , List <SqlIdentifier > projectedFields ,
959
- @ Nullable Criteria criteria , Sort sort , Pageable page ) {
963
+ @ Nullable CriteriaDefinition criteria , Sort sort , Pageable page ) {
960
964
return new DefaultTypedSelectSpec <>(table , projectedFields , criteria , sort , page , this .typeToRead ,
961
965
this .mappingFunction );
962
966
}
@@ -1204,11 +1208,12 @@ class DefaultGenericUpdateSpec implements GenericUpdateSpec, UpdateMatchingSpec
1204
1208
1205
1209
private final @ Nullable Class <?> typeToUpdate ;
1206
1210
private final @ Nullable SqlIdentifier table ;
1207
- private final @ Nullable Update assignments ;
1208
- private final @ Nullable Criteria where ;
1211
+ private final @ Nullable org . springframework . data . relational . core . query . Update assignments ;
1212
+ private final @ Nullable CriteriaDefinition where ;
1209
1213
1210
1214
DefaultGenericUpdateSpec (@ Nullable Class <?> typeToUpdate , @ Nullable SqlIdentifier table ,
1211
- @ Nullable Update assignments , @ Nullable Criteria where ) {
1215
+ @ Nullable org .springframework .data .relational .core .query .Update assignments ,
1216
+ @ Nullable CriteriaDefinition where ) {
1212
1217
this .typeToUpdate = typeToUpdate ;
1213
1218
this .table = table ;
1214
1219
this .assignments = assignments ;
@@ -1220,11 +1225,20 @@ public UpdateMatchingSpec using(Update update) {
1220
1225
1221
1226
Assert .notNull (update , "Update must not be null" );
1222
1227
1228
+ return new DefaultGenericUpdateSpec (this .typeToUpdate , this .table ,
1229
+ org .springframework .data .relational .core .query .Update .from (update .getAssignments ()), this .where );
1230
+ }
1231
+
1232
+ @ Override
1233
+ public UpdateMatchingSpec using (org .springframework .data .relational .core .query .Update update ) {
1234
+
1235
+ Assert .notNull (update , "Update must not be null" );
1236
+
1223
1237
return new DefaultGenericUpdateSpec (this .typeToUpdate , this .table , update , this .where );
1224
1238
}
1225
1239
1226
1240
@ Override
1227
- public UpdateSpec matching (Criteria criteria ) {
1241
+ public UpdateSpec matching (CriteriaDefinition criteria ) {
1228
1242
1229
1243
Assert .notNull (criteria , "Criteria must not be null" );
1230
1244
@@ -1333,11 +1347,12 @@ private UpdatedRowsFetchSpec exchange(SqlIdentifier table) {
1333
1347
}
1334
1348
Object id = columns .remove (ids .get (0 )); // do not update the Id column.
1335
1349
1336
- Update update = null ;
1350
+ org . springframework . data . relational . core . query . Update update = null ;
1337
1351
1338
1352
for (SqlIdentifier column : columns .keySet ()) {
1339
1353
if (update == null ) {
1340
- update = Update .update (dataAccessStrategy .toSql (column ), columns .get (column ));
1354
+ update = org .springframework .data .relational .core .query .Update .update (dataAccessStrategy .toSql (column ),
1355
+ columns .get (column ));
1341
1356
} else {
1342
1357
update = update .set (dataAccessStrategy .toSql (column ), columns .get (column ));
1343
1358
}
@@ -1376,16 +1391,17 @@ class DefaultDeleteSpec<T> implements DeleteMatchingSpec, TypedDeleteSpec<T> {
1376
1391
1377
1392
private final @ Nullable Class <T > typeToDelete ;
1378
1393
private final @ Nullable SqlIdentifier table ;
1379
- private final @ Nullable Criteria where ;
1394
+ private final @ Nullable CriteriaDefinition where ;
1380
1395
1381
- DefaultDeleteSpec (@ Nullable Class <T > typeToDelete , @ Nullable SqlIdentifier table , @ Nullable Criteria where ) {
1396
+ DefaultDeleteSpec (@ Nullable Class <T > typeToDelete , @ Nullable SqlIdentifier table ,
1397
+ @ Nullable CriteriaDefinition where ) {
1382
1398
this .typeToDelete = typeToDelete ;
1383
1399
this .table = table ;
1384
1400
this .where = where ;
1385
1401
}
1386
1402
1387
1403
@ Override
1388
- public DeleteSpec matching (Criteria criteria ) {
1404
+ public DeleteSpec matching (CriteriaDefinition criteria ) {
1389
1405
1390
1406
Assert .notNull (criteria , "Criteria must not be null!" );
1391
1407
0 commit comments