From 0e169aa23e56d63245237eb0278084629a25be20 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Mon, 19 May 2025 14:32:01 +0200 Subject: [PATCH] =?UTF-8?q?Document=20`createCollection(=E2=80=A6)`=20anno?= =?UTF-8?q?tation=20usage.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes: #4978 Original Pull Request: #4979 --- .../data/mongodb/core/MongoOperations.java | 12 ++++++++++++ .../data/mongodb/core/ReactiveMongoOperations.java | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java index 65396bc7f..22b8e930a 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java @@ -259,9 +259,21 @@ public interface MongoOperations extends FluentMongoOperations { /** * Create an uncapped collection with a name based on the provided entity class. + *

+ * This method derives {@link CollectionOptions} from the given {@code entityClass} using + * {@link org.springframework.data.mongodb.core.mapping.Document} and + * {@link org.springframework.data.mongodb.core.mapping.TimeSeries} annotations to determine: + *

+ * Any other options such as change stream options, schema-based details (validation, encryption) are not considered + * and must be provided through {@link #createCollection(Class, CollectionOptions)} or + * {@link #createCollection(String, CollectionOptions)}. * * @param entityClass class that determines the collection to create. * @return the created collection. + * @see #createCollection(Class, CollectionOptions) */ MongoCollection createCollection(Class entityClass); diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveMongoOperations.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveMongoOperations.java index 90f2d2345..19802b47f 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveMongoOperations.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveMongoOperations.java @@ -214,9 +214,21 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { /** * Create an uncapped collection with a name based on the provided entity class. + *

+ * This method derives {@link CollectionOptions} from the given {@code entityClass} using + * {@link org.springframework.data.mongodb.core.mapping.Document} and + * {@link org.springframework.data.mongodb.core.mapping.TimeSeries} annotations to determine: + *

    + *
  • Collation
  • + *
  • TimeSeries time and meta fields, granularity and {@code expireAfter}
  • + *
+ * Any other options such as change stream options, schema-based details (validation, encryption) are not considered + * and must be provided through {@link #createCollection(Class, CollectionOptions)} or + * {@link #createCollection(String, CollectionOptions)}. * * @param entityClass class that determines the collection to create. * @return the created collection. + * @see #createCollection(Class, CollectionOptions) */ Mono> createCollection(Class entityClass);