diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Meta.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Meta.java index 95d3dc167..a32435c5d 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Meta.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Meta.java @@ -169,11 +169,32 @@ public class Meta { return flags; } + /** + * When set to {@literal true}, aggregation stages can write data to disk. + * + * @return {@literal null} if not set. + * @since 3.0 + */ + @Nullable + public Boolean getAllowDiskUse() { + return allowDiskUse; + } + + /** + * Set to {@literal true}, to allow aggregation stages to write data to disk. + * + * @param allowDiskUse use {@literal null} for server defaults. + * @since 3.0 + */ + public void setAllowDiskUse(@Nullable Boolean allowDiskUse) { + this.allowDiskUse = allowDiskUse; + } + /** * @return */ public boolean hasValues() { - return !this.values.isEmpty() || !this.flags.isEmpty() || this.cursorBatchSize != null; + return !this.values.isEmpty() || !this.flags.isEmpty() || this.cursorBatchSize != null || this.allowDiskUse != null; } /** @@ -247,27 +268,6 @@ public class Meta { return ObjectUtils.nullSafeEquals(this.flags, other.flags); } - /** - * When set to true, aggregation stages can write data to disk. - * - * @return {@literal null} if not set. - * @since 3.0 - */ - @Nullable - public Boolean getAllowDiskUse() { - return allowDiskUse; - } - - /** - * Set to true, to allow aggregation stages to write data to disk. - * - * @param allowDiskUse use {@literal null} for server defaults. - * @since 3.0 - */ - public void setAllowDiskUse(@Nullable Boolean allowDiskUse) { - this.allowDiskUse = allowDiskUse; - } - /** * {@link CursorOption} represents {@code OP_QUERY} wire protocol flags to change the behavior of queries. * diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/Meta.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/Meta.java index 64159605e..929e3a63e 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/Meta.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/Meta.java @@ -46,7 +46,7 @@ public @interface Meta { * Sets the number of documents to return per batch.
* Use {@literal 0 (zero)} for no limit. A negative limit closes the cursor after returning a single * batch indicating to the server that the client will not ask for a subsequent one. - * + * * @return {@literal 0 (zero)} by default. * @since 2.1 */ @@ -68,7 +68,7 @@ public @interface Meta { org.springframework.data.mongodb.core.query.Meta.CursorOption[] flags() default {}; /** - * When set to true, aggregation stages can write data to disk. + * When set to {@literal true}, aggregation stages can write data to disk. * * @return {@literal false} by default. * @since 3.0 diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/AggregationUtils.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/AggregationUtils.java index d780d43c1..e78cb6504 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/AggregationUtils.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/AggregationUtils.java @@ -94,7 +94,7 @@ class AggregationUtils { builder.cursorBatchSize(meta.getCursorBatchSize()); } - if(meta.getMaxTimeMsec() != null && meta.getMaxTimeMsec() > 0) { + if (meta.getMaxTimeMsec() != null && meta.getMaxTimeMsec() > 0) { builder.maxTime(Duration.ofMillis(meta.getMaxTimeMsec())); } diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/MongoQueryMethod.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/MongoQueryMethod.java index d97a84632..a2ec157f1 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/MongoQueryMethod.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/MongoQueryMethod.java @@ -293,7 +293,7 @@ public class MongoQueryMethod extends QueryMethod { } } - if(meta.allowDiskUse()) { + if (meta.allowDiskUse()) { metaAttributes.setAllowDiskUse(meta.allowDiskUse()); }