From 9f2219533083dc833d34c1c96dffdad20c8be4c3 Mon Sep 17 00:00:00 2001 From: Christoph Strobl Date: Mon, 19 Jun 2017 10:17:52 +0200 Subject: [PATCH] DATAMONGO-1697 - Update MongoOperations JavaDoc regarding mapping limitations. We now explicitly mention mapping/support limitations for API variants like count(Query, String) not having domain type specific information that allows field specific mapping. --- .../data/mongodb/core/MongoOperations.java | 35 ++++++++++++------ .../mongodb/core/ReactiveMongoOperations.java | 36 +++++++++++++------ 2 files changed, 50 insertions(+), 21 deletions(-) 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 2935e167d..9fbc1bed2 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 @@ -282,7 +282,10 @@ public interface MongoOperations extends FluentMongoOperations { ScriptOperations scriptOps(); /** - * Returns a new {@link BulkOperations} for the given collection. + * Returns a new {@link BulkOperations} for the given collection.
+ * NOTE: Any additional support for field mapping, etc. is not available for {@literal update} or + * {@literal remove} operations in bulk mode due to the lack of domain type information. Use + * {@link #bulkOps(BulkMode, Class, String)} to get full type specific support. * * @param mode the {@link BulkMode} to use for bulk operations, must not be {@literal null}. * @param collectionName the name of the collection to work on, must not be {@literal null} or empty. @@ -609,7 +612,9 @@ public interface MongoOperations extends FluentMongoOperations { T findOne(Query query, Class entityClass, String collectionName); /** - * Determine result of given {@link Query} contains at least one element. + * Determine result of given {@link Query} contains at least one element.
+ * NOTE: Any additional support for query/field mapping, etc. is not available due to the lack of + * domain type information. Use {@link #exists(Query, Class, String)} to get full type specific support. * * @param query the {@link Query} class that specifies the criteria used to find a record. * @param collectionName name of the collection to check for objects. @@ -793,7 +798,7 @@ public interface MongoOperations extends FluentMongoOperations { /** * Returns the number of documents for the given {@link Query} querying the given collection. The given {@link Query} * must solely consist of document field references as we lack type information to map potential property references - * onto document fields. TO make sure the query gets mapped, use {@link #count(Query, Class, String)}. + * onto document fields. Use {@link #count(Query, Class, String)} to get full type specific support. * * @param query * @param collectionName must not be {@literal null} or empty. @@ -916,7 +921,9 @@ public interface MongoOperations extends FluentMongoOperations { /** * Performs an upsert. If no document is found that matches the query, a new document is created and inserted by - * combining the query document and the update document. + * combining the query document and the update document.
+ * NOTE: Any additional support for field mapping, versions, etc. is not available due to the lack of + * domain type information. Use {@link #upsert(Query, Update, Class, String)} to get full type specific support. * * @param query the query document that specifies the criteria used to select a record to be updated * @param update the update document that contains the updated object or $ operators to manipulate the existing @@ -952,7 +959,9 @@ public interface MongoOperations extends FluentMongoOperations { /** * Updates the first object that is found in the specified collection that matches the query document criteria with - * the provided updated document. + * the provided updated document.
+ * NOTE: Any additional support for field mapping, versions, etc. is not available due to the lack of + * domain type information. Use {@link #updateFirst(Query, Update, Class, String)} to get full type specific support. * * @param query the query document that specifies the criteria used to select a record to be updated * @param update the update document that contains the updated object or $ operators to manipulate the existing @@ -989,7 +998,9 @@ public interface MongoOperations extends FluentMongoOperations { /** * Updates all objects that are found in the specified collection that matches the query document criteria with the - * provided updated document. + * provided updated document.
+ * NOTE: Any additional support for field mapping, versions, etc. is not available due to the lack of + * domain type information. Use {@link #updateMulti(Query, Update, Class, String)} to get full type specific support. * * @param query the query document that specifies the criteria used to select a record to be updated * @param update the update document that contains the updated object or $ operators to manipulate the existing @@ -1048,7 +1059,9 @@ public interface MongoOperations extends FluentMongoOperations { /** * Remove all documents from the specified collection that match the provided query document criteria. There is no - * conversion/mapping done for any criteria using the id field. + * conversion/mapping done for any criteria using the id field.
+ * NOTE: Any additional support for field mapping is not available due to the lack of domain type + * information. Use {@link #remove(Query, Class, String)} to get full type specific support. * * @param query the query document that specifies the criteria used to remove a record * @param collectionName name of the collection where the objects will removed @@ -1056,10 +1069,12 @@ public interface MongoOperations extends FluentMongoOperations { DeleteResult remove(Query query, String collectionName); /** - * Returns and removes all documents form the specified collection that match the provided query. + * Returns and removes all documents form the specified collection that match the provided query.
+ * NOTE: Any additional support for field mapping is not available due to the lack of domain type + * information. Use {@link #findAllAndRemove(Query, Class, String)} to get full type specific support. * - * @param query - * @param collectionName + * @param query must not be {@literal null}. + * @param collectionName must not be {@literal null}. * @return * @since 1.5 */ 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 7390a2462..310c8de25 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 @@ -15,6 +15,9 @@ */ package org.springframework.data.mongodb.core; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + import java.util.Collection; import org.bson.Document; @@ -34,9 +37,6 @@ import com.mongodb.client.result.DeleteResult; import com.mongodb.client.result.UpdateResult; import com.mongodb.reactivestreams.client.MongoCollection; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - /** * Interface that specifies a basic set of MongoDB operations executed in a reactive way. *

@@ -285,7 +285,9 @@ public interface ReactiveMongoOperations { Mono findOne(Query query, Class entityClass, String collectionName); /** - * Determine result of given {@link Query} contains at least one element. + * Determine result of given {@link Query} contains at least one element.
+ * NOTE: Any additional support for query/field mapping, etc. is not available due to the lack of + * domain type information. Use {@link #exists(Query, Class, String)} to get full type specific support. * * @param query the {@link Query} class that specifies the criteria used to find a record. * @param collectionName name of the collection to check for objects. @@ -494,7 +496,7 @@ public interface ReactiveMongoOperations { /** * Returns the number of documents for the given {@link Query} querying the given collection. The given {@link Query} * must solely consist of document field references as we lack type information to map potential property references - * onto document fields. TO make sure the query gets mapped, use {@link #count(Query, Class, String)}. + * onto document fields. Use {@link #count(Query, Class, String)} to get full type specific support. * * @param query * @param collectionName must not be {@literal null} or empty. @@ -707,7 +709,9 @@ public interface ReactiveMongoOperations { /** * Performs an upsert. If no document is found that matches the query, a new document is created and inserted by - * combining the query document and the update document. + * combining the query document and the update document.
+ * NOTE: Any additional support for field mapping, versions, etc. is not available due to the lack of + * domain type information. Use {@link #upsert(Query, Update, Class, String)} to get full type specific support. * * @param query the query document that specifies the criteria used to select a record to be updated * @param update the update document that contains the updated object or $ operators to manipulate the existing @@ -743,7 +747,9 @@ public interface ReactiveMongoOperations { /** * Updates the first object that is found in the specified collection that matches the query document criteria with - * the provided updated document. + * the provided updated document.
+ * NOTE: Any additional support for field mapping, versions, etc. is not available due to the lack of + * domain type information. Use {@link #updateFirst(Query, Update, Class, String)} to get full type specific support. * * @param query the query document that specifies the criteria used to select a record to be updated * @param update the update document that contains the updated object or $ operators to manipulate the existing @@ -755,7 +761,9 @@ public interface ReactiveMongoOperations { /** * Updates the first object that is found in the specified collection that matches the query document criteria with - * the provided updated document. + * the provided updated document.
+ * NOTE: Any additional support for field mapping, versions, etc. is not available due to the lack of + * domain type information. Use {@link #updateFirst(Query, Update, Class, String)} to get full type specific support. * * @param query the query document that specifies the criteria used to select a record to be updated * @param update the update document that contains the updated object or $ operators to manipulate the existing @@ -780,7 +788,9 @@ public interface ReactiveMongoOperations { /** * Updates all objects that are found in the specified collection that matches the query document criteria with the - * provided updated document. + * provided updated document.
+ * NOTE: Any additional support for field mapping, versions, etc. is not available due to the lack of + * domain type information. Use {@link #updateMulti(Query, Update, Class, String)} to get full type specific support. * * @param query the query document that specifies the criteria used to select a record to be updated * @param update the update document that contains the updated object or $ operators to manipulate the existing @@ -859,7 +869,9 @@ public interface ReactiveMongoOperations { /** * Remove all documents from the specified collection that match the provided query document criteria. There is no - * conversion/mapping done for any criteria using the id field. + * conversion/mapping done for any criteria using the id field.
+ * NOTE: Any additional support for field mapping is not available due to the lack of domain type + * information. Use {@link #remove(Query, Class, String)} to get full type specific support. * * @param query the query document that specifies the criteria used to remove a record * @param collectionName name of the collection where the objects will removed @@ -867,7 +879,9 @@ public interface ReactiveMongoOperations { Mono remove(Query query, String collectionName); /** - * Returns and removes all documents form the specified collection that match the provided query. + * Returns and removes all documents form the specified collection that match the provided query.
+ * NOTE: Any additional support for field mapping is not available due to the lack of domain type + * information. Use {@link #findAllAndRemove(Query, Class, String)} to get full type specific support. * * @param query * @param collectionName