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 0fe456aa7..e4a4b0868 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 @@ -1258,11 +1258,13 @@ public interface MongoOperations extends FluentMongoOperations { * Spring's * Type Conversion" for more details. *

- *

* Insert is used to initially store the object into the database. To update an existing object use the save method. + *

+ * The {@code objectToSave} must not be collection-like. * * @param objectToSave the object to store in the collection. Must not be {@literal null}. * @return the inserted object. + * @throws IllegalArgumentException in case the {@code objectToSave} is collection-like. */ T insert(T objectToSave); @@ -1273,10 +1275,13 @@ public interface MongoOperations extends FluentMongoOperations { * configured otherwise, an instance of {@link MappingMongoConverter} will be used. *

* Insert is used to initially store the object into the database. To update an existing object use the save method. + *

+ * The {@code objectToSave} must not be collection-like. * * @param objectToSave the object to store in the collection. Must not be {@literal null}. * @param collectionName name of the collection to store the object in. Must not be {@literal null}. * @return the inserted object. + * @throws IllegalArgumentException in case the {@code objectToSave} is collection-like. */ T insert(T objectToSave, String collectionName); @@ -1320,11 +1325,11 @@ public interface MongoOperations extends FluentMongoOperations { * Spring's * Type Conversion" for more details. *

- * The {@literal objectToSave} must not be collection like. + * The {@code objectToSave} must not be collection-like. * * @param objectToSave the object to store in the collection. Must not be {@literal null}. * @return the saved object. - * @throws IllegalArgumentException in case the objectToSave is collection like. + * @throws IllegalArgumentException in case the {@code objectToSave} is collection-like. */ T save(T objectToSave); @@ -1341,13 +1346,12 @@ public interface MongoOperations extends FluentMongoOperations { * https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation">Spring's Type * Conversion" for more details. *

- * The {@literal objectToSave} must not be collection like. - * + * The {@code objectToSave} must not be collection-like. * * @param objectToSave the object to store in the collection. Must not be {@literal null}. * @param collectionName name of the collection to store the object in. Must not be {@literal null}. * @return the saved object. - * @throws IllegalArgumentException in case the objectToSave is collection like. + * @throws IllegalArgumentException in case the {@code objectToSave} is collection-like. */ T save(T objectToSave, 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 a1a0925b7..fb1c26030 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 @@ -1038,11 +1038,13 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { * Spring's * Type Conversion" for more details. *

- *

* Insert is used to initially store the object into the database. To update an existing object use the save method. + *

+ * The {@code objectToSave} must not be collection-like. * * @param objectToSave the object to store in the collection. Must not be {@literal null}. * @return the inserted object. + * @throws IllegalArgumentException in case the {@code objectToSave} is collection-like. */ Mono insert(T objectToSave); @@ -1053,10 +1055,13 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { * configured otherwise, an instance of {@link MappingMongoConverter} will be used. *

* Insert is used to initially store the object into the database. To update an existing object use the save method. + *

+ * The {@code objectToSave} must not be collection-like. * * @param objectToSave the object to store in the collection. Must not be {@literal null}. * @param collectionName name of the collection to store the object in. Must not be {@literal null}. * @return the inserted object. + * @throws IllegalArgumentException in case the {@code objectToSave} is collection-like. */ Mono insert(T objectToSave, String collectionName); @@ -1098,7 +1103,6 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { * Spring's * Type Conversion" for more details. *

- *

* Insert is used to initially store the object into the database. To update an existing object use the save method. * * @param objectToSave the object to store in the collection. Must not be {@literal null}. @@ -1145,9 +1149,12 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { * property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See * Spring's * Type Conversion" for more details. + *

+ * The {@code objectToSave} must not be collection-like. * * @param objectToSave the object to store in the collection. Must not be {@literal null}. * @return the saved object. + * @throws IllegalArgumentException in case the {@code objectToSave} is collection-like. */ Mono save(T objectToSave); @@ -1167,6 +1174,7 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations { * @param objectToSave the object to store in the collection. Must not be {@literal null}. * @param collectionName name of the collection to store the object in. Must not be {@literal null}. * @return the saved object. + * @throws IllegalArgumentException in case the {@code objectToSave} is collection-like. */ Mono save(T objectToSave, String collectionName);