56
56
import org .springframework .dao .IncorrectResultSizeDataAccessException ;
57
57
import org .springframework .dao .InvalidDataAccessApiUsageException ;
58
58
import org .springframework .data .domain .*;
59
+ import org .springframework .data .domain .ExampleMatcher .GenericPropertyMatcher ;
60
+ import org .springframework .data .domain .ExampleMatcher .StringMatcher ;
59
61
import org .springframework .data .domain .Sort .Direction ;
60
62
import org .springframework .data .domain .Sort .Order ;
61
63
import org .springframework .data .jpa .domain .Specification ;
@@ -1243,7 +1245,7 @@ void scrollByExampleOffset() {
1243
1245
matching ().withMatcher ("firstname" , GenericPropertyMatcher ::startsWith ).withIgnorePaths ("age" , "createdAt" ,
1244
1246
"dateOfBirth" ));
1245
1247
Window <User > firstWindow = repository .findBy (example ,
1246
- q -> q .limit (2 ).sortBy (Sort .by ("firstname" )).scroll (OffsetScrollPosition . initial ()));
1248
+ q -> q .limit (2 ).sortBy (Sort .by ("firstname" )).scroll (ScrollPosition . offset ()));
1247
1249
1248
1250
assertThat (firstWindow ).containsExactly (jane1 , jane2 );
1249
1251
assertThat (firstWindow .hasNext ()).isTrue ();
@@ -1269,7 +1271,7 @@ void scrollByExampleKeyset() {
1269
1271
matching ().withMatcher ("firstname" , GenericPropertyMatcher ::startsWith ).withIgnorePaths ("age" , "createdAt" ,
1270
1272
"dateOfBirth" ));
1271
1273
Window <User > firstWindow = repository .findBy (example ,
1272
- q -> q .limit (1 ).sortBy (Sort .by ("firstname" , "emailAddress" )).scroll (KeysetScrollPosition . initial ()));
1274
+ q -> q .limit (1 ).sortBy (Sort .by ("firstname" , "emailAddress" )).scroll (ScrollPosition . keyset ()));
1273
1275
1274
1276
assertThat (firstWindow ).containsOnly (jane1 );
1275
1277
assertThat (firstWindow .hasNext ()).isTrue ();
@@ -1295,12 +1297,12 @@ void scrollByExampleKeysetBackward() {
1295
1297
matching ().withMatcher ("firstname" , GenericPropertyMatcher ::startsWith ).withIgnorePaths ("age" , "createdAt" ,
1296
1298
"dateOfBirth" ));
1297
1299
Window <User > firstWindow = repository .findBy (example ,
1298
- q -> q .limit (4 ).sortBy (Sort .by ("firstname" , "emailAddress" )).scroll (KeysetScrollPosition . initial ()));
1300
+ q -> q .limit (4 ).sortBy (Sort .by ("firstname" , "emailAddress" )).scroll (ScrollPosition . keyset ()));
1299
1301
1300
1302
KeysetScrollPosition scrollPosition = (KeysetScrollPosition ) firstWindow .positionAt (2 );
1301
1303
Window <User > previousWindow = repository .findBy (example ,
1302
1304
q -> q .limit (1 ).sortBy (Sort .by ("firstname" , "emailAddress" ))
1303
- .scroll (KeysetScrollPosition . of (scrollPosition .getKeys (), KeysetScrollPosition . Direction . Backward )));
1305
+ .scroll (ScrollPosition . backward (scrollPosition .getKeys ())));
1304
1306
1305
1307
assertThat (previousWindow ).containsOnly (jane2 );
1306
1308
assertThat (previousWindow .hasNext ()).isTrue ();
@@ -1317,7 +1319,7 @@ void scrollByPredicateOffset() {
1317
1319
repository .saveAllAndFlush (Arrays .asList (john1 , john2 , jane1 , jane2 ));
1318
1320
1319
1321
Window <User > firstWindow = repository .findBy (QUser .user .firstname .startsWith ("J" ),
1320
- q -> q .limit (2 ).sortBy (Sort .by ("firstname" )).scroll (OffsetScrollPosition . initial ()));
1322
+ q -> q .limit (2 ).sortBy (Sort .by ("firstname" )).scroll (ScrollPosition . offset ()));
1321
1323
1322
1324
assertThat (firstWindow ).containsExactly (jane1 , jane2 );
1323
1325
assertThat (firstWindow .hasNext ()).isTrue ();
@@ -1340,7 +1342,7 @@ void scrollByPredicateKeyset() {
1340
1342
repository .saveAllAndFlush (Arrays .asList (john1 , john2 , jane1 , jane2 ));
1341
1343
1342
1344
Window <User > firstWindow = repository .findBy (QUser .user .firstname .startsWith ("J" ),
1343
- q -> q .limit (1 ).sortBy (Sort .by ("firstname" , "emailAddress" )).scroll (KeysetScrollPosition . initial ()));
1345
+ q -> q .limit (1 ).sortBy (Sort .by ("firstname" , "emailAddress" )).scroll (ScrollPosition . keyset ()));
1344
1346
1345
1347
assertThat (firstWindow ).containsOnly (jane1 );
1346
1348
assertThat (firstWindow .hasNext ()).isTrue ();
@@ -1363,16 +1365,14 @@ void scrollByPredicateKeysetBackward() {
1363
1365
repository .saveAllAndFlush (Arrays .asList (john1 , john2 , jane1 , jane2 ));
1364
1366
1365
1367
Window <User > firstWindow = repository .findBy (QUser .user .firstname .startsWith ("J" ),
1366
- q -> q .limit (3 ).sortBy (Sort .by ("firstname" , "emailAddress" )).scroll (KeysetScrollPosition . initial ()));
1368
+ q -> q .limit (3 ).sortBy (Sort .by ("firstname" , "emailAddress" )).scroll (ScrollPosition . keyset ()));
1367
1369
1368
1370
assertThat (firstWindow ).containsExactly (jane1 , jane2 , john1 );
1369
1371
assertThat (firstWindow .hasNext ()).isTrue ();
1370
1372
1371
1373
KeysetScrollPosition scrollPosition = (KeysetScrollPosition ) firstWindow .positionAt (2 );
1372
- KeysetScrollPosition backward = KeysetScrollPosition .of (scrollPosition .getKeys (),
1373
- KeysetScrollPosition .Direction .Backward );
1374
1374
Window <User > previousWindow = repository .findBy (QUser .user .firstname .startsWith ("J" ),
1375
- q -> q .limit (3 ).sortBy (Sort .by ("firstname" , "emailAddress" )).scroll (backward ));
1375
+ q -> q .limit (3 ).sortBy (Sort .by ("firstname" , "emailAddress" )).scroll (scrollPosition . backward () ));
1376
1376
1377
1377
assertThat (previousWindow ).containsExactly (jane1 , jane2 );
1378
1378
@@ -1391,16 +1391,14 @@ void scrollByPartTreeKeysetBackward() {
1391
1391
repository .saveAllAndFlush (Arrays .asList (john1 , john2 , jane1 , jane2 ));
1392
1392
1393
1393
Window <User > firstWindow = repository .findTop3ByFirstnameStartingWithOrderByFirstnameAscEmailAddressAsc ("J" ,
1394
- KeysetScrollPosition . initial ());
1394
+ ScrollPosition . keyset ());
1395
1395
1396
1396
assertThat (firstWindow ).containsExactly (jane1 , jane2 , john1 );
1397
1397
assertThat (firstWindow .hasNext ()).isTrue ();
1398
1398
1399
1399
KeysetScrollPosition scrollPosition = (KeysetScrollPosition ) firstWindow .positionAt (2 );
1400
- KeysetScrollPosition backward = KeysetScrollPosition .of (scrollPosition .getKeys (),
1401
- KeysetScrollPosition .Direction .Backward );
1402
1400
Window <User > previousWindow = repository .findTop3ByFirstnameStartingWithOrderByFirstnameAscEmailAddressAsc ("J" ,
1403
- backward );
1401
+ scrollPosition . backward () );
1404
1402
1405
1403
assertThat (previousWindow ).containsExactly (jane1 , jane2 );
1406
1404
@@ -1914,7 +1912,7 @@ void findByCollectionWithPageRequest() {
1914
1912
1915
1913
flushTestUsers ();
1916
1914
1917
- Page <User > userPage = repository .findByAgeIn (List .of (28 , 35 ), ( PageRequest ) PageRequest .of (0 , 2 ));
1915
+ Page <User > userPage = repository .findByAgeIn (List .of (28 , 35 ), PageRequest .of (0 , 2 ));
1918
1916
1919
1917
assertThat (userPage ).hasSize (2 );
1920
1918
assertThat (userPage .getTotalElements ()).isEqualTo (2 );
0 commit comments