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 6753f31c1..23ad63f1c 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 @@ -260,9 +260,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); @@ -998,7 +1010,8 @@ public interface MongoOperations extends FluentMongoOperations { * @see Update * @see AggregationUpdate */ - @Nullable T findAndModify(Query query, UpdateDefinition update, FindAndModifyOptions options, Class entityClass); + @Nullable T findAndModify(Query query, UpdateDefinition update, FindAndModifyOptions options, + Class entityClass); /** * Triggers findAndModify @@ -1021,8 +1034,8 @@ public interface MongoOperations extends FluentMongoOperations { * @see Update * @see AggregationUpdate */ - @Nullable T findAndModify(Query query, UpdateDefinition update, FindAndModifyOptions options, Class entityClass, - String collectionName); + @Nullable T findAndModify(Query query, UpdateDefinition update, FindAndModifyOptions options, + Class entityClass, String collectionName); /** * Triggers @@ -1102,7 +1115,8 @@ public interface MongoOperations extends FluentMongoOperations { * as it is after the update. * @since 2.1 */ - default @Nullable T findAndReplace(Query query, T replacement, FindAndReplaceOptions options, String collectionName) { + default @Nullable T findAndReplace(Query query, T replacement, FindAndReplaceOptions options, + String collectionName) { Assert.notNull(replacement, "Replacement must not be null"); return findAndReplace(query, replacement, options, (Class) ClassUtils.getUserClass(replacement), collectionName); @@ -1154,8 +1168,8 @@ public interface MongoOperations extends FluentMongoOperations { * {@link #getCollectionName(Class) derived} from the given replacement value. * @since 2.1 */ - default @Nullable T findAndReplace(Query query, S replacement, FindAndReplaceOptions options, Class entityType, - Class resultType) { + default @Nullable T findAndReplace(Query query, S replacement, FindAndReplaceOptions options, + Class entityType, Class resultType) { return findAndReplace(query, replacement, options, entityType, getCollectionName(ClassUtils.getUserClass(entityType)), resultType); 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 14f6ee263..ab86c6083 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); diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/Document.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/Document.java index ef4980fab..cf6001b8e 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/Document.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/Document.java @@ -42,8 +42,8 @@ public @interface Document { /** * The collection the document representing the entity is supposed to be stored in. If not configured, a default * collection name will be derived from the type's name. The attribute supports SpEL expressions to dynamically - * calculate the collection to based on a per operation basis. - * + * calculate the collection to based on a per-operation basis. + * * @return the name of the collection to be used. */ @AliasFor("collection") @@ -53,7 +53,7 @@ public @interface Document { * The collection the document representing the entity is supposed to be stored in. If not configured, a default * collection name will be derived from the type's name. The attribute supports SpEL expressions to dynamically * calculate the collection to based on a per operation basis. - * + * * @return the name of the collection to be used. */ @AliasFor("value") diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/TimeSeries.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/TimeSeries.java index efe0cd870..e3293e74b 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/TimeSeries.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/TimeSeries.java @@ -41,7 +41,7 @@ public @interface TimeSeries { /** * The collection the document representing the entity is supposed to be stored in. If not configured, a default * collection name will be derived from the type's name. The attribute supports SpEL expressions to dynamically - * calculate the collection based on a per operation basis. + * calculate the collection based on a per-operation basis. * * @return the name of the collection to be used. * @see Document#collection() diff --git a/src/main/antora/modules/ROOT/pages/mongodb/mongo-encryption.adoc b/src/main/antora/modules/ROOT/pages/mongodb/mongo-encryption.adoc index 14e866cf1..4c34c3831 100644 --- a/src/main/antora/modules/ROOT/pages/mongodb/mongo-encryption.adoc +++ b/src/main/antora/modules/ROOT/pages/mongodb/mongo-encryption.adoc @@ -188,7 +188,7 @@ It is possible to create custom annotations out of the provided ones. MongoDB Collection Info:: + ==== -[source,java,indent=0,subs="verbatim,quotes",role="thrid"] +[source,json,indent=0,subs="verbatim,quotes",role="thrid"] ---- { name: 'patient',