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 b63c9e8b3..bd97b4d6c 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
+ * 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
@@ -304,7 +307,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.
@@ -313,7 +316,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.
@@ -329,7 +332,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
*/
@@ -343,7 +346,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
@@ -353,7 +356,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
@@ -368,7 +371,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
@@ -382,7 +385,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.
@@ -395,7 +398,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}.
@@ -406,7 +409,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
@@ -419,7 +422,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
@@ -432,7 +435,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
@@ -445,7 +448,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
@@ -459,7 +462,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
@@ -473,7 +476,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
@@ -490,7 +493,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
@@ -501,7 +504,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
@@ -519,7 +522,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.
@@ -536,7 +539,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.
@@ -546,8 +549,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
@@ -556,7 +561,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
@@ -565,7 +570,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.
@@ -581,7 +586,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.
@@ -597,7 +602,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.
@@ -609,7 +614,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.
@@ -866,7 +873,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
@@ -878,7 +885,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.
@@ -889,8 +896,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.
@@ -902,7 +911,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.
@@ -915,7 +924,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.
@@ -926,8 +935,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.
@@ -939,7 +950,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.
@@ -951,14 +962,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.
*/
@@ -967,7 +978,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
*/
@@ -976,7 +987,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
@@ -985,18 +996,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
*/
@@ -1004,7 +1019,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
@@ -1016,7 +1031,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
@@ -1027,7 +1042,7 @@ public interface MongoOperations {
/**
* Returns the underlying {@link MongoConverter}.
- *
+ *
* @return
*/
MongoConverter getConverter();