@@ -865,7 +865,8 @@ public <T> List<T> find(Query query, Class<T> entityClass, String collectionName
865
865
Assert .notNull (collectionName , "CollectionName must not be null" );
866
866
Assert .notNull (entityClass , "EntityClass must not be null" );
867
867
868
- return doFind (collectionName , createDelegate (query ), query .getQueryObject (), query .getFieldsObject (), entityClass ,
868
+ return doFind (collectionName , createDelegate (query ), query .getQueryObject (), query .getFieldsObject (),
869
+ query .getSortObject (), entityClass ,
869
870
new QueryCursorPreparer (query , entityClass ));
870
871
}
871
872
@@ -899,14 +900,15 @@ <T> Window<T> doScroll(Query query, Class<?> sourceClass, Class<T> targetClass,
899
900
operations .getIdPropertyName (sourceClass ));
900
901
901
902
List <T > result = doFind (collectionName , createDelegate (query ), keysetPaginationQuery .query (),
902
- keysetPaginationQuery .fields (), sourceClass ,
903
+ keysetPaginationQuery .fields (), keysetPaginationQuery . sort (), sourceClass ,
903
904
new QueryCursorPreparer (query , keysetPaginationQuery .sort (), limit , 0 , sourceClass ), callback );
904
905
905
906
return ScrollUtils .createWindow (query , result , sourceClass , operations );
906
907
}
907
908
908
909
List <T > result = doFind (collectionName , createDelegate (query ), query .getQueryObject (), query .getFieldsObject (),
909
- sourceClass , new QueryCursorPreparer (query , query .getSortObject (), limit , query .getSkip (), sourceClass ),
910
+ query .getSortObject (), sourceClass ,
911
+ new QueryCursorPreparer (query , query .getSortObject (), limit , query .getSkip (), sourceClass ),
910
912
callback );
911
913
912
914
return ScrollUtils .createWindow (result , query .getLimit (), OffsetScrollPosition .positionFunction (query .getSkip ()));
@@ -2559,8 +2561,8 @@ protected <T> T doFindOne(String collectionName, CollectionPreparer<MongoCollect
2559
2561
* @return the List of converted objects.
2560
2562
*/
2561
2563
protected <T > List <T > doFind (String collectionName , CollectionPreparer <MongoCollection <Document >> collectionPreparer ,
2562
- Document query , Document fields , Class <T > entityClass ) {
2563
- return doFind (collectionName , collectionPreparer , query , fields , entityClass , null ,
2564
+ Document query , Document fields , Document sort , Class <T > entityClass ) {
2565
+ return doFind (collectionName , collectionPreparer , query , fields , sort , entityClass , null ,
2564
2566
new ReadDocumentCallback <>(this .mongoConverter , entityClass , collectionName ));
2565
2567
}
2566
2568
@@ -2579,21 +2581,21 @@ protected <T> List<T> doFind(String collectionName, CollectionPreparer<MongoColl
2579
2581
* @return the {@link List} of converted objects.
2580
2582
*/
2581
2583
protected <T > List <T > doFind (String collectionName , CollectionPreparer <MongoCollection <Document >> collectionPreparer ,
2582
- Document query , Document fields , Class <T > entityClass , CursorPreparer preparer ) {
2583
- return doFind (collectionName , collectionPreparer , query , fields , entityClass , preparer ,
2584
+ Document query , Document fields , Document sort , Class <T > entityClass , CursorPreparer preparer ) {
2585
+ return doFind (collectionName , collectionPreparer , query , fields , sort , entityClass , preparer ,
2584
2586
new ReadDocumentCallback <>(mongoConverter , entityClass , collectionName ));
2585
2587
}
2586
2588
2587
2589
protected <S , T > List <T > doFind (String collectionName ,
2588
2590
CollectionPreparer <MongoCollection <Document >> collectionPreparer , Document query , Document fields ,
2589
- Class <S > entityClass , @ Nullable CursorPreparer preparer , DocumentCallback <T > objectCallback ) {
2591
+ Document sort , Class <S > entityClass , @ Nullable CursorPreparer preparer , DocumentCallback <T > objectCallback ) {
2590
2592
2591
2593
MongoPersistentEntity <?> entity = mappingContext .getPersistentEntity (entityClass );
2592
2594
2593
2595
QueryContext queryContext = queryOperations .createQueryContext (new BasicQuery (query , fields ));
2594
2596
Document mappedFields = queryContext .getMappedFields (entity , EntityProjection .nonProjecting (entityClass ));
2595
2597
Document mappedQuery = queryContext .getMappedQuery (entity );
2596
- Document mappedSort = getMappedSortObject (query , entityClass );
2598
+ Document mappedSort = getMappedSortObject (sort , entityClass );
2597
2599
2598
2600
if (LOGGER .isDebugEnabled ()) {
2599
2601
LOGGER .debug (String .format ("find using query: %s fields: %s sort: %s for class: %s in collection: %s" ,
0 commit comments