3131
3232import org .junit .jupiter .api .Disabled ;
3333import org .junit .jupiter .api .Test ;
34-
3534import org .springframework .beans .factory .annotation .Autowired ;
3635import org .springframework .context .annotation .Bean ;
3736import org .springframework .context .annotation .Configuration ;
4443import org .springframework .data .annotation .ReadOnlyProperty ;
4544import org .springframework .data .annotation .Version ;
4645import org .springframework .data .domain .PageRequest ;
46+ import org .springframework .data .domain .Pageable ;
4747import org .springframework .data .domain .Persistable ;
4848import org .springframework .data .domain .Sort ;
4949import org .springframework .data .jdbc .testing .EnabledOnFeature ;
@@ -236,10 +236,30 @@ void findAllByQuery() {
236236 Iterable <SimpleListParent > reloadedById = template .findAll (query , SimpleListParent .class );
237237
238238 assertThat (reloadedById ) //
239- .extracting (e -> e .id , e -> e .name , e -> e .content .size ()) //
239+ .extracting (e -> e .id , e -> e .name , e -> e .content .size ()) //
240240 .containsExactly (tuple (two .id , two .name , 2 ));
241241 }
242242
243+ @ Test // GH-1601
244+ void findAllByQueryWithConflictingSort () {
245+
246+ SimpleListParent one = template .save (SimpleListParent .of ("one" , "one_1" ));
247+ SimpleListParent two = template .save (SimpleListParent .of ("two" , "two_1" , "two_2" ));
248+ SimpleListParent three = template .save (SimpleListParent .of ("three" , "three_1" , "three_2" , "three_3" ));
249+
250+ CriteriaDefinition criteria = CriteriaDefinition .empty ();
251+ Query query = Query .query (criteria );
252+ query .sort (Sort .by (Sort .Direction .ASC , "id" ));
253+
254+ Pageable pageable = PageRequest .of (0 , 3 , Sort .by (Sort .Direction .DESC , "name" ));
255+
256+ Iterable <SimpleListParent > reloadedById = template .findAll (query , SimpleListParent .class , pageable );
257+
258+ assertThat (reloadedById ) //
259+ .extracting (e -> e .id ) //
260+ .containsExactly (two .id , three .id , one .id );
261+ }
262+
243263 @ Test // GH-1803
244264 void findAllByQueryWithColumns () {
245265
@@ -252,7 +272,7 @@ void findAllByQueryWithColumns() {
252272 Iterable <SimpleListParent > reloadedById = template .findAll (query , SimpleListParent .class );
253273
254274 assertThat (reloadedById ) //
255- .extracting (e -> e .id , e -> e .name , e -> e .content .size ()) //
275+ .extracting (e -> e .id , e -> e .name , e -> e .content .size ()) //
256276 .containsExactly (tuple (two .id , null , 2 ));
257277 }
258278
@@ -1382,8 +1402,7 @@ void recordOfSet() {
13821402 void mapWithEnumKey () {
13831403
13841404 EnumMapOwner enumMapOwner = template
1385- .save (
1386- new EnumMapOwner (null , "OwnerName" , Map .of (Color .BLUE , new MapElement ("Element" ))));
1405+ .save (new EnumMapOwner (null , "OwnerName" , Map .of (Color .BLUE , new MapElement ("Element" ))));
13871406
13881407 Iterable <EnumMapOwner > enumMapOwners = template .findAll (EnumMapOwner .class );
13891408
@@ -2220,8 +2239,7 @@ public Short getVersion() {
22202239 @ Table ("BEFORE_CONVERT_CALLBACK_FOR_SAVE_BATCH" )
22212240 static class BeforeConvertCallbackForSaveBatch {
22222241
2223- @ Id
2224- private String id ;
2242+ @ Id private String id ;
22252243
22262244 private String name ;
22272245
0 commit comments