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 ed1e3b965..355777dcd 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 @@ -57,6 +57,10 @@ import com.mongodb.client.result.UpdateResult; * Interface that specifies a basic set of MongoDB operations. Implemented by {@link MongoTemplate}. Not often used but * a useful option for extensibility and testability (as it can be easily mocked, stubbed, or be the target of a JDK * proxy). + *

+ * NOTE: Some operations cannot be executed within a MongoDB transaction. Please refer to the MongoDB + * specific documentation to learn more about Multi + * Document Transactions. * * @author Thomas Risberg * @author Mark Pollack @@ -289,12 +293,15 @@ public interface MongoOperations extends FluentMongoOperations { Set getCollectionNames(); /** - * Get a collection by name, creating it if it doesn't exist. + * Get a {@link MongoCollection} by its name. The returned collection may not exists yet (except in local memory) and + * is created on first interaction with the server. Collections can be explicitly created via + * {@link #createCollection(Class)}. Please make sure to check if the collection {@link #collectionExists(Class) + * exists} first. *

* Translate any exceptions as necessary. * * @param collectionName name of the collection. Must not be {@literal null}. - * @return an existing collection or a newly created one. + * @return an existing collection or one created on first server interaction. */ MongoCollection getCollection(String collectionName); 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 798804dd8..aa841366f 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 @@ -56,6 +56,10 @@ import com.mongodb.reactivestreams.client.MongoCollection; * Implemented by {@link ReactiveMongoTemplate}. Not often used but a useful option for extensibility and testability * (as it can be easily mocked, stubbed, or be the target of a JDK proxy). Command execution using * {@link ReactiveMongoOperations} is deferred until subscriber subscribes to the {@link Publisher}. + *

+ * NOTE: Some operations cannot be executed within a MongoDB transaction. Please refer to the MongoDB + * specific documentation to learn more about Multi + * Document Transactions. * * @author Mark Paluch * @author Christoph Strobl @@ -277,12 +281,15 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { Flux getCollectionNames(); /** - * Get a collection by name, creating it if it doesn't exist. + * Get a {@link MongoCollection} by name. The returned collection may not exists yet (except in local memory) and is + * created on first interaction with the server. Collections can be explicitly created via + * {@link #createCollection(Class)}. Please make sure to check if the collection {@link #collectionExists(Class) + * exists} first. *

* Translate any exceptions as necessary. * * @param collectionName name of the collection. - * @return an existing collection or a newly created one. + * @return an existing collection or one created on first server interaction. */ MongoCollection getCollection(String collectionName);