diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Query.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Query.java index a608a59a9b..82f0a29cad 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Query.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Query.java @@ -184,7 +184,9 @@ public Query withHint(Document hint) { public Query with(Pageable pageable) { if (pageable.isUnpaged()) { - return this; + this.limit = 0; // default value + this.skip = 0; // default value + return with(pageable.getSort()); } this.limit = pageable.getPageSize(); @@ -204,6 +206,7 @@ public Query with(Sort sort) { Assert.notNull(sort, "Sort must not be null!"); if (sort.isUnsorted()) { + this.sort = sort; // Sort.unsorted() return this; }