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 6d3e13d4a..915c13b4c 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 @@ -1,6 +1,6 @@ /* * Copyright 2011-2015 the original author or authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -48,7 +48,7 @@ import com.mongodb.WriteResult; * 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). - * + * * @author Thomas Risberg * @author Mark Pollack * @author Oliver Gierke @@ -61,7 +61,7 @@ public interface MongoOperations { /** * The collection name used for the specified class by this template. - * + * * @param entityClass must not be {@literal null}. * @return */ @@ -71,7 +71,7 @@ public interface MongoOperations { * Execute the a MongoDB command expressed as a JSON string. This will call the method JSON.parse that is part of the * MongoDB driver to convert the JSON string to a DBObject. Any errors that result from executing this command will be * converted into Spring's DAO exception hierarchy. - * + * * @param jsonCommand a MongoDB command expressed as a JSON string. */ CommandResult executeCommand(String jsonCommand); @@ -79,7 +79,7 @@ public interface MongoOperations { /** * Execute a MongoDB command. Any errors that result from executing this command will be converted into Spring's DAO * exception hierarchy. - * + * * @param command a MongoDB command */ CommandResult executeCommand(DBObject command); @@ -87,7 +87,7 @@ public interface MongoOperations { /** * Execute a MongoDB command. Any errors that result from executing this command will be converted into Spring's DAO * exception hierarchy. - * + * * @param command a MongoDB command * @param options query options to use * @deprecated since 1.7. Please use {@link #executeCommand(DBObject, ReadPreference)}, as the MongoDB Java driver @@ -99,7 +99,7 @@ public interface MongoOperations { /** * Execute a MongoDB command. Any errors that result from executing this command will be converted into Spring's data * access exception hierarchy. - * + * * @param command a MongoDB command, must not be {@literal null}. * @param readPreference read preferences to use, can be {@literal null}. * @return @@ -109,7 +109,7 @@ public interface MongoOperations { /** * Execute a MongoDB query and iterate over the query results on a per-document basis with a DocumentCallbackHandler. - * + * * @param query the query class that specifies the criteria used to find a record and also an optional fields * specification * @param collectionName name of the collection to retrieve the objects from @@ -121,7 +121,7 @@ public interface MongoOperations { * Executes a {@link DbCallback} translating any exceptions as necessary. *
* Allows for returning a result object, that is a domain object or a collection of domain objects. - * + * * @param
* Returns a {@link CloseableIterator} that wraps the a Mongo DB {@link Cursor} that needs to be closed.
- *
+ *
* @param
* Returns a {@link CloseableIterator} that wraps the a Mongo DB {@link Cursor} that needs to be closed.
- *
+ *
* @param
+ * 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.
* @return {@link BulkOperations} on the named collection
@@ -319,7 +322,7 @@ public interface MongoOperations {
/**
* Returns a new {@link BulkOperations} for the given entity type.
- *
+ *
* @param mode the {@link BulkMode} to use for bulk operations, must not be {@literal null}.
* @param entityType the name of the entity class, must not be {@literal null}.
* @return {@link BulkOperations} on the named collection associated of the given entity class.
@@ -328,7 +331,7 @@ public interface MongoOperations {
/**
* Returns a new {@link BulkOperations} for the given entity type and collection name.
- *
+ *
* @param mode the {@link BulkMode} to use for bulk operations, must not be {@literal null}.
* @param entityClass the name of the entity class, must not be {@literal null}.
* @param collectionName the name of the collection to work on, must not be {@literal null} or empty.
@@ -344,7 +347,7 @@ public interface MongoOperations {
*
* If your collection does not contain a homogeneous collection of types, this operation will not be an efficient way
* to map objects since the test for class type is done in the client and not on the server.
- *
+ *
* @param entityClass the parameterized type of the returned list
* @return the converted collection
*/
@@ -358,7 +361,7 @@ public interface MongoOperations {
*
* If your collection does not contain a homogeneous collection of types, this operation will not be an efficient way
* to map objects since the test for class type is done in the client and not on the server.
- *
+ *
* @param entityClass the parameterized type of the returned list.
* @param collectionName name of the collection to retrieve the objects from
* @return the converted collection
@@ -368,7 +371,7 @@ public interface MongoOperations {
/**
* Execute a group operation over the entire collection. The group operation entity class should match the 'shape' of
* the returned object that takes int account the initial document structure as well as any finalize functions.
- *
+ *
* @param criteria The criteria that restricts the row that are considered for grouping. If not specified all rows are
* considered.
* @param inputCollectionName the collection where the group operation will read from
@@ -383,7 +386,7 @@ public interface MongoOperations {
* Execute a group operation restricting the rows to those which match the provided Criteria. The group operation
* entity class should match the 'shape' of the returned object that takes int account the initial document structure
* as well as any finalize functions.
- *
+ *
* @param criteria The criteria that restricts the row that are considered for grouping. If not specified all rows are
* considered.
* @param inputCollectionName the collection where the group operation will read from
@@ -397,7 +400,7 @@ public interface MongoOperations {
/**
* Execute an aggregation operation. The raw results will be mapped to the given entity class. The name of the
* inputCollection is derived from the inputType of the aggregation.
- *
+ *
* @param aggregation The {@link TypedAggregation} specification holding the aggregation operations, must not be
* {@literal null}.
* @param collectionName The name of the input collection to use for the aggreation.
@@ -410,7 +413,7 @@ public interface MongoOperations {
/**
* Execute an aggregation operation. The raw results will be mapped to the given entity class. The name of the
* inputCollection is derived from the inputType of the aggregation.
- *
+ *
* @param aggregation The {@link TypedAggregation} specification holding the aggregation operations, must not be
* {@literal null}.
* @param outputType The parameterized type of the returned list, must not be {@literal null}.
@@ -421,7 +424,7 @@ public interface MongoOperations {
/**
* Execute an aggregation operation. The raw results will be mapped to the given entity class.
- *
+ *
* @param aggregation The {@link Aggregation} specification holding the aggregation operations, must not be
* {@literal null}.
* @param inputType the inputType where the aggregation operation will read from, must not be {@literal null} or
@@ -434,7 +437,7 @@ public interface MongoOperations {
/**
* Execute an aggregation operation. The raw results will be mapped to the given entity class.
- *
+ *
* @param aggregation The {@link Aggregation} specification holding the aggregation operations, must not be
* {@literal null}.
* @param collectionName the collection where the aggregation operation will read from, must not be {@literal null} or
@@ -447,7 +450,7 @@ public interface MongoOperations {
/**
* Execute a map-reduce operation. The map-reduce operation will be formed with an output type of INLINE
- *
+ *
* @param inputCollectionName the collection where the map-reduce will read from
* @param mapFunction The JavaScript map function
* @param reduceFunction The JavaScript reduce function
@@ -460,7 +463,7 @@ public interface MongoOperations {
/**
* Execute a map-reduce operation that takes additional map-reduce options.
- *
+ *
* @param inputCollectionName the collection where the map-reduce will read from
* @param mapFunction The JavaScript map function
* @param reduceFunction The JavaScript reduce function
@@ -474,7 +477,7 @@ public interface MongoOperations {
/**
* Execute a map-reduce operation that takes a query. The map-reduce operation will be formed with an output type of
* INLINE
- *
+ *
* @param query The query to use to select the data for the map phase
* @param inputCollectionName the collection where the map-reduce will read from
* @param mapFunction The JavaScript map function
@@ -488,7 +491,7 @@ public interface MongoOperations {
/**
* Execute a map-reduce operation that takes a query and additional map-reduce options
- *
+ *
* @param query The query to use to select the data for the map phase
* @param inputCollectionName the collection where the map-reduce will read from
* @param mapFunction The JavaScript map function
@@ -505,7 +508,7 @@ public interface MongoOperations {
* information to determine the collection the query is ran against. Note, that MongoDB limits the number of results
* by default. Make sure to add an explicit limit to the {@link NearQuery} if you expect a particular number of
* results.
- *
+ *
* @param near must not be {@literal null}.
* @param entityClass must not be {@literal null}.
* @return
@@ -516,7 +519,7 @@ public interface MongoOperations {
* Returns {@link GeoResults} for all entities matching the given {@link NearQuery}. Note, that MongoDB limits the
* number of results by default. Make sure to add an explicit limit to the {@link NearQuery} if you expect a
* particular number of results.
- *
+ *
* @param near must not be {@literal null}.
* @param entityClass must not be {@literal null}.
* @param collectionName the collection to trigger the query against. If no collection name is given the entity class
@@ -534,7 +537,7 @@ public interface MongoOperations {
*
* The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more
* feature rich {@link Query}.
- *
+ *
* @param query the query class that specifies the criteria used to find a record and also an optional fields
* specification
* @param entityClass the parameterized type of the returned list.
@@ -551,7 +554,7 @@ public interface MongoOperations {
*
* The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more
* feature rich {@link Query}.
- *
+ *
* @param query the query class that specifies the criteria used to find a record and also an optional fields
* specification
* @param entityClass the parameterized type of the returned list.
@@ -561,8 +564,10 @@ public interface MongoOperations {
+ * 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.
* @return
@@ -571,7 +576,7 @@ public interface MongoOperations {
/**
* Determine result of given {@link Query} contains at least one element.
- *
+ *
* @param query the {@link Query} class that specifies the criteria used to find a record.
* @param entityClass the parameterized type.
* @return
@@ -580,7 +585,7 @@ public interface MongoOperations {
/**
* Determine result of given {@link Query} contains at least one element.
- *
+ *
* @param query the {@link Query} class that specifies the criteria used to find a record.
* @param entityClass the parameterized type.
* @param collectionName name of the collection to check for objects.
@@ -596,7 +601,7 @@ public interface MongoOperations {
*
* The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more
* feature rich {@link Query}.
- *
+ *
* @param query the query class that specifies the criteria used to find a record and also an optional fields
* specification
* @param entityClass the parameterized type of the returned list.
@@ -612,7 +617,7 @@ public interface MongoOperations {
*
* The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more
* feature rich {@link Query}.
- *
+ *
* @param query the query class that specifies the criteria used to find a record and also an optional fields
* specification
* @param entityClass the parameterized type of the returned list.
@@ -624,7 +629,7 @@ public interface MongoOperations {
/**
* Returns a document with the given id mapped onto the given class. The collection the query is ran against will be
* derived from the given target class as well.
- *
+ *
* @param
+ * 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
* object.
@@ -881,7 +888,7 @@ public interface MongoOperations {
/**
* 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.
- *
+ *
* @param query the query document that specifies the criteria used to select a record to be upserted
* @param update the update document that contains the updated object or $ operators to manipulate the existing object
* @param entityClass class of the pojo to be operated on
@@ -893,7 +900,7 @@ public interface MongoOperations {
/**
* Updates the first object that is found in the collection of the entity class that matches the query document with
* the provided update document.
- *
+ *
* @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
* object.
@@ -904,8 +911,10 @@ public interface MongoOperations {
/**
* 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
* object.
@@ -917,7 +926,7 @@ public interface MongoOperations {
/**
* Updates the first object that is found in the specified collection that matches the query document criteria with
* the provided updated document.
- *
+ *
* @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
* object.
@@ -930,7 +939,7 @@ public interface MongoOperations {
/**
* Updates all objects that are found in the collection for the entity class that matches the query document criteria
* with the provided updated document.
- *
+ *
* @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
* object.
@@ -941,8 +950,10 @@ public interface MongoOperations {
/**
* 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
* object.
@@ -954,7 +965,7 @@ public interface MongoOperations {
/**
* Updates all objects that are found in the collection for the entity class that matches the query document criteria
* with the provided updated document.
- *
+ *
* @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
* object.
@@ -966,14 +977,14 @@ public interface MongoOperations {
/**
* Remove the given object from the collection by id.
- *
+ *
* @param object
*/
WriteResult remove(Object object);
/**
* Removes the given object from the given collection.
- *
+ *
* @param object
* @param collection must not be {@literal null} or empty.
*/
@@ -982,7 +993,7 @@ public interface MongoOperations {
/**
* Remove all documents that match the provided query document criteria from the the collection used to store the
* entityClass. The Class parameter is also used to help convert the Id of the object if it is present in the query.
- *
+ *
* @param query
* @param entityClass
*/
@@ -991,7 +1002,7 @@ public interface MongoOperations {
/**
* Remove all documents that match the provided query document criteria from the the collection used to store the
* entityClass. The Class parameter is also used to help convert the Id of the object if it is present in the query.
- *
+ *
* @param query
* @param entityClass
* @param collectionName
@@ -1000,18 +1011,22 @@ public interface MongoOperations {
/**
* 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
*/
WriteResult remove(Query query, String collectionName);
/**
- * Returns and removes all documents form the specified collection that match the provided query.
- *
- * @param query
- * @param collectionName
+ * 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 must not be {@literal null}.
+ * @param collectionName must not be {@literal null}.
* @return
* @since 1.5
*/
@@ -1019,7 +1034,7 @@ public interface MongoOperations {
/**
* Returns and removes all documents matching the given query form the collection used to store the entityClass.
- *
+ *
* @param query
* @param entityClass
* @return
@@ -1031,7 +1046,7 @@ public interface MongoOperations {
* Returns and removes all documents that match the provided query document criteria from the the collection used to
* store the entityClass. The Class parameter is also used to help convert the Id of the object if it is present in
* the query.
- *
+ *
* @param query
* @param entityClass
* @param collectionName
@@ -1042,7 +1057,7 @@ public interface MongoOperations {
/**
* Returns the underlying {@link MongoConverter}.
- *
+ *
* @return
*/
MongoConverter getConverter();