Browse Source

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.
pull/482/head
Christoph Strobl 9 years ago
parent
commit
b3f691c128
  1. 207
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java

207
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. * Copyright 2011-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * 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 * 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 * a useful option for extensibility and testability (as it can be easily mocked, stubbed, or be the target of a JDK
* proxy). * proxy).
* *
* @author Thomas Risberg * @author Thomas Risberg
* @author Mark Pollack * @author Mark Pollack
* @author Oliver Gierke * @author Oliver Gierke
@ -61,7 +61,7 @@ public interface MongoOperations {
/** /**
* The collection name used for the specified class by this template. * The collection name used for the specified class by this template.
* *
* @param entityClass must not be {@literal null}. * @param entityClass must not be {@literal null}.
* @return * @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 * 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 * 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. * converted into Spring's DAO exception hierarchy.
* *
* @param jsonCommand a MongoDB command expressed as a JSON string. * @param jsonCommand a MongoDB command expressed as a JSON string.
*/ */
CommandResult executeCommand(String jsonCommand); 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 * Execute a MongoDB command. Any errors that result from executing this command will be converted into Spring's DAO
* exception hierarchy. * exception hierarchy.
* *
* @param command a MongoDB command * @param command a MongoDB command
*/ */
CommandResult executeCommand(DBObject 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 * Execute a MongoDB command. Any errors that result from executing this command will be converted into Spring's DAO
* exception hierarchy. * exception hierarchy.
* *
* @param command a MongoDB command * @param command a MongoDB command
* @param options query options to use * @param options query options to use
* @deprecated since 1.7. Please use {@link #executeCommand(DBObject, ReadPreference)}, as the MongoDB Java driver * @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 * Execute a MongoDB command. Any errors that result from executing this command will be converted into Spring's data
* access exception hierarchy. * access exception hierarchy.
* *
* @param command a MongoDB command, must not be {@literal null}. * @param command a MongoDB command, must not be {@literal null}.
* @param readPreference read preferences to use, can be {@literal null}. * @param readPreference read preferences to use, can be {@literal null}.
* @return * @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. * 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 * @param query the query class that specifies the criteria used to find a record and also an optional fields
* specification * specification
* @param collectionName name of the collection to retrieve the objects from * @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. * Executes a {@link DbCallback} translating any exceptions as necessary.
* <p/> * <p/>
* Allows for returning a result object, that is a domain object or a collection of domain objects. * Allows for returning a result object, that is a domain object or a collection of domain objects.
* *
* @param <T> return type * @param <T> return type
* @param action callback object that specifies the MongoDB actions to perform on the passed in DB instance. * @param action callback object that specifies the MongoDB actions to perform on the passed in DB instance.
* @return a result object returned by the action or <tt>null</tt> * @return a result object returned by the action or <tt>null</tt>
@ -132,7 +132,7 @@ public interface MongoOperations {
* Executes the given {@link CollectionCallback} on the entity collection of the specified class. * Executes the given {@link CollectionCallback} on the entity collection of the specified class.
* <p/> * <p/>
* Allows for returning a result object, that is a domain object or a collection of domain objects. * Allows for returning a result object, that is a domain object or a collection of domain objects.
* *
* @param entityClass class that determines the collection to use * @param entityClass class that determines the collection to use
* @param <T> return type * @param <T> return type
* @param action callback object that specifies the MongoDB action * @param action callback object that specifies the MongoDB action
@ -144,7 +144,7 @@ public interface MongoOperations {
* Executes the given {@link CollectionCallback} on the collection of the given name. * Executes the given {@link CollectionCallback} on the collection of the given name.
* <p/> * <p/>
* Allows for returning a result object, that is a domain object or a collection of domain objects. * Allows for returning a result object, that is a domain object or a collection of domain objects.
* *
* @param <T> return type * @param <T> return type
* @param collectionName the name of the collection that specifies which DBCollection instance will be passed into * @param collectionName the name of the collection that specifies which DBCollection instance will be passed into
* @param action callback object that specifies the MongoDB action the callback action. * @param action callback object that specifies the MongoDB action the callback action.
@ -158,7 +158,7 @@ public interface MongoOperations {
* href=http://www.mongodb.org/display/DOCS/Java+Driver+Concurrency>Java Driver Concurrency</a>} * href=http://www.mongodb.org/display/DOCS/Java+Driver+Concurrency>Java Driver Concurrency</a>}
* <p/> * <p/>
* Allows for returning a result object, that is a domain object or a collection of domain objects. * Allows for returning a result object, that is a domain object or a collection of domain objects.
* *
* @param <T> return type * @param <T> return type
* @param action callback that specified the MongoDB actions to perform on the DB instance * @param action callback that specified the MongoDB actions to perform on the DB instance
* @return a result object returned by the action or <tt>null</tt> * @return a result object returned by the action or <tt>null</tt>
@ -173,7 +173,7 @@ public interface MongoOperations {
* {@link Cursor}. * {@link Cursor}.
* <p> * <p>
* Returns a {@link CloseableIterator} that wraps the a Mongo DB {@link Cursor} that needs to be closed. * Returns a {@link CloseableIterator} that wraps the a Mongo DB {@link Cursor} that needs to be closed.
* *
* @param <T> element return type * @param <T> element return type
* @param query * @param query
* @param entityType * @param entityType
@ -184,7 +184,7 @@ public interface MongoOperations {
/** /**
* Create an uncapped collection with a name based on the provided entity class. * Create an uncapped collection with a name based on the provided entity class.
* *
* @param entityClass class that determines the collection to create * @param entityClass class that determines the collection to create
* @return the created collection * @return the created collection
*/ */
@ -192,7 +192,7 @@ public interface MongoOperations {
/** /**
* Create a collection with a name based on the provided entity class using the options. * Create a collection with a name based on the provided entity class using the options.
* *
* @param entityClass class that determines the collection to create * @param entityClass class that determines the collection to create
* @param collectionOptions options to use when creating the collection. * @param collectionOptions options to use when creating the collection.
* @return the created collection * @return the created collection
@ -201,7 +201,7 @@ public interface MongoOperations {
/** /**
* Create an uncapped collection with the provided name. * Create an uncapped collection with the provided name.
* *
* @param collectionName name of the collection * @param collectionName name of the collection
* @return the created collection * @return the created collection
*/ */
@ -209,7 +209,7 @@ public interface MongoOperations {
/** /**
* Create a collection with the provided name and options. * Create a collection with the provided name and options.
* *
* @param collectionName name of the collection * @param collectionName name of the collection
* @param collectionOptions options to use when creating the collection. * @param collectionOptions options to use when creating the collection.
* @return the created collection * @return the created collection
@ -218,7 +218,7 @@ public interface MongoOperations {
/** /**
* A set of collection names. * A set of collection names.
* *
* @return list of collection names * @return list of collection names
*/ */
Set<String> getCollectionNames(); Set<String> getCollectionNames();
@ -227,7 +227,7 @@ public interface MongoOperations {
* Get a collection by name, creating it if it doesn't exist. * Get a collection by name, creating it if it doesn't exist.
* <p/> * <p/>
* Translate any exceptions as necessary. * Translate any exceptions as necessary.
* *
* @param collectionName name of the collection * @param collectionName name of the collection
* @return an existing collection or a newly created one. * @return an existing collection or a newly created one.
*/ */
@ -237,7 +237,7 @@ public interface MongoOperations {
* Check to see if a collection with a name indicated by the entity class exists. * Check to see if a collection with a name indicated by the entity class exists.
* <p/> * <p/>
* Translate any exceptions as necessary. * Translate any exceptions as necessary.
* *
* @param entityClass class that determines the name of the collection * @param entityClass class that determines the name of the collection
* @return true if a collection with the given name is found, false otherwise. * @return true if a collection with the given name is found, false otherwise.
*/ */
@ -247,7 +247,7 @@ public interface MongoOperations {
* Check to see if a collection with a given name exists. * Check to see if a collection with a given name exists.
* <p/> * <p/>
* Translate any exceptions as necessary. * Translate any exceptions as necessary.
* *
* @param collectionName name of the collection * @param collectionName name of the collection
* @return true if a collection with the given name is found, false otherwise. * @return true if a collection with the given name is found, false otherwise.
*/ */
@ -257,7 +257,7 @@ public interface MongoOperations {
* Drop the collection with the name indicated by the entity class. * Drop the collection with the name indicated by the entity class.
* <p/> * <p/>
* Translate any exceptions as necessary. * Translate any exceptions as necessary.
* *
* @param entityClass class that determines the collection to drop/delete. * @param entityClass class that determines the collection to drop/delete.
*/ */
<T> void dropCollection(Class<T> entityClass); <T> void dropCollection(Class<T> entityClass);
@ -266,36 +266,39 @@ public interface MongoOperations {
* Drop the collection with the given name. * Drop the collection with the given name.
* <p/> * <p/>
* Translate any exceptions as necessary. * Translate any exceptions as necessary.
* *
* @param collectionName name of the collection to drop/delete. * @param collectionName name of the collection to drop/delete.
*/ */
void dropCollection(String collectionName); void dropCollection(String collectionName);
/** /**
* Returns the operations that can be performed on indexes * Returns the operations that can be performed on indexes
* *
* @return index operations on the named collection * @return index operations on the named collection
*/ */
IndexOperations indexOps(String collectionName); IndexOperations indexOps(String collectionName);
/** /**
* Returns the operations that can be performed on indexes * Returns the operations that can be performed on indexes
* *
* @return index operations on the named collection associated with the given entity class * @return index operations on the named collection associated with the given entity class
*/ */
IndexOperations indexOps(Class<?> entityClass); IndexOperations indexOps(Class<?> entityClass);
/** /**
* Returns the {@link ScriptOperations} that can be performed on {@link com.mongodb.DB} level. * Returns the {@link ScriptOperations} that can be performed on {@link com.mongodb.DB} level.
* *
* @return * @return
* @since 1.7 * @since 1.7
*/ */
ScriptOperations scriptOps(); ScriptOperations scriptOps();
/** /**
* Returns a new {@link BulkOperations} for the given collection. * Returns a new {@link BulkOperations} for the given collection. <br />
* * <strong>NOTE:</strong> 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 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. * @param collectionName the name of the collection to work on, must not be {@literal null} or empty.
* @return {@link BulkOperations} on the named collection * @return {@link BulkOperations} on the named collection
@ -304,7 +307,7 @@ public interface MongoOperations {
/** /**
* Returns a new {@link BulkOperations} for the given entity type. * 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 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}. * @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. * @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. * 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 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 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. * @param collectionName the name of the collection to work on, must not be {@literal null} or empty.
@ -329,7 +332,7 @@ public interface MongoOperations {
* <p/> * <p/>
* If your collection does not contain a homogeneous collection of types, this operation will not be an efficient way * 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. * 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 entityClass the parameterized type of the returned list
* @return the converted collection * @return the converted collection
*/ */
@ -343,7 +346,7 @@ public interface MongoOperations {
* <p/> * <p/>
* If your collection does not contain a homogeneous collection of types, this operation will not be an efficient way * 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. * 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 entityClass the parameterized type of the returned list.
* @param collectionName name of the collection to retrieve the objects from * @param collectionName name of the collection to retrieve the objects from
* @return the converted collection * @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 * 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. * 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 * @param criteria The criteria that restricts the row that are considered for grouping. If not specified all rows are
* considered. * considered.
* @param inputCollectionName the collection where the group operation will read from * @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 * 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 * entity class should match the 'shape' of the returned object that takes int account the initial document structure
* as well as any finalize functions. * 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 * @param criteria The criteria that restricts the row that are considered for grouping. If not specified all rows are
* considered. * considered.
* @param inputCollectionName the collection where the group operation will read from * @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 * 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. * inputCollection is derived from the inputType of the aggregation.
* *
* @param aggregation The {@link TypedAggregation} specification holding the aggregation operations, must not be * @param aggregation The {@link TypedAggregation} specification holding the aggregation operations, must not be
* {@literal null}. * {@literal null}.
* @param collectionName The name of the input collection to use for the aggreation. * @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 * 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. * inputCollection is derived from the inputType of the aggregation.
* *
* @param aggregation The {@link TypedAggregation} specification holding the aggregation operations, must not be * @param aggregation The {@link TypedAggregation} specification holding the aggregation operations, must not be
* {@literal null}. * {@literal null}.
* @param outputType The parameterized type of the returned list, 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. * 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 * @param aggregation The {@link Aggregation} specification holding the aggregation operations, must not be
* {@literal null}. * {@literal null}.
* @param inputType the inputType where the aggregation operation will read from, must not be {@literal null} or * @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. * 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 * @param aggregation The {@link Aggregation} specification holding the aggregation operations, must not be
* {@literal null}. * {@literal null}.
* @param collectionName the collection where the aggregation operation will read from, must not be {@literal null} or * @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 * 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 inputCollectionName the collection where the map-reduce will read from
* @param mapFunction The JavaScript map function * @param mapFunction The JavaScript map function
* @param reduceFunction The JavaScript reduce 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. * Execute a map-reduce operation that takes additional map-reduce options.
* *
* @param inputCollectionName the collection where the map-reduce will read from * @param inputCollectionName the collection where the map-reduce will read from
* @param mapFunction The JavaScript map function * @param mapFunction The JavaScript map function
* @param reduceFunction The JavaScript reduce 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 * Execute a map-reduce operation that takes a query. The map-reduce operation will be formed with an output type of
* INLINE * INLINE
* *
* @param query The query to use to select the data for the map phase * @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 inputCollectionName the collection where the map-reduce will read from
* @param mapFunction The JavaScript map function * @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 * 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 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 inputCollectionName the collection where the map-reduce will read from
* @param mapFunction The JavaScript map function * @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 * 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 * by default. Make sure to add an explicit limit to the {@link NearQuery} if you expect a particular number of
* results. * results.
* *
* @param near must not be {@literal null}. * @param near must not be {@literal null}.
* @param entityClass must not be {@literal null}. * @param entityClass must not be {@literal null}.
* @return * @return
@ -501,7 +504,7 @@ public interface MongoOperations {
* Returns {@link GeoResults} for all entities matching the given {@link NearQuery}. Note, that MongoDB limits the * 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 * number of results by default. Make sure to add an explicit limit to the {@link NearQuery} if you expect a
* particular number of results. * particular number of results.
* *
* @param near must not be {@literal null}. * @param near must not be {@literal null}.
* @param entityClass 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 * @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 {
* <p/> * <p/>
* The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more * The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more
* feature rich {@link Query}. * feature rich {@link Query}.
* *
* @param query the query class that specifies the criteria used to find a record and also an optional fields * @param query the query class that specifies the criteria used to find a record and also an optional fields
* specification * specification
* @param entityClass the parameterized type of the returned list. * @param entityClass the parameterized type of the returned list.
@ -536,7 +539,7 @@ public interface MongoOperations {
* <p/> * <p/>
* The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more * The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more
* feature rich {@link Query}. * feature rich {@link Query}.
* *
* @param query the query class that specifies the criteria used to find a record and also an optional fields * @param query the query class that specifies the criteria used to find a record and also an optional fields
* specification * specification
* @param entityClass the parameterized type of the returned list. * @param entityClass the parameterized type of the returned list.
@ -546,8 +549,10 @@ public interface MongoOperations {
<T> T findOne(Query query, Class<T> entityClass, String collectionName); <T> T findOne(Query query, Class<T> 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. <br />
* * <strong>NOTE:</strong> 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 query the {@link Query} class that specifies the criteria used to find a record.
* @param collectionName name of the collection to check for objects. * @param collectionName name of the collection to check for objects.
* @return * @return
@ -556,7 +561,7 @@ public interface MongoOperations {
/** /**
* Determine result of given {@link Query} contains at least one element. * 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 query the {@link Query} class that specifies the criteria used to find a record.
* @param entityClass the parameterized type. * @param entityClass the parameterized type.
* @return * @return
@ -565,7 +570,7 @@ public interface MongoOperations {
/** /**
* Determine result of given {@link Query} contains at least one element. * 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 query the {@link Query} class that specifies the criteria used to find a record.
* @param entityClass the parameterized type. * @param entityClass the parameterized type.
* @param collectionName name of the collection to check for objects. * @param collectionName name of the collection to check for objects.
@ -581,7 +586,7 @@ public interface MongoOperations {
* <p/> * <p/>
* The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more * The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more
* feature rich {@link Query}. * feature rich {@link Query}.
* *
* @param query the query class that specifies the criteria used to find a record and also an optional fields * @param query the query class that specifies the criteria used to find a record and also an optional fields
* specification * specification
* @param entityClass the parameterized type of the returned list. * @param entityClass the parameterized type of the returned list.
@ -597,7 +602,7 @@ public interface MongoOperations {
* <p/> * <p/>
* The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more * The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more
* feature rich {@link Query}. * feature rich {@link Query}.
* *
* @param query the query class that specifies the criteria used to find a record and also an optional fields * @param query the query class that specifies the criteria used to find a record and also an optional fields
* specification * specification
* @param entityClass the parameterized type of the returned list. * @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 * 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. * derived from the given target class as well.
* *
* @param <T> * @param <T>
* @param id the id of the document to return. * @param id the id of the document to return.
* @param entityClass the type the document shall be converted into. * @param entityClass the type the document shall be converted into.
@ -619,7 +624,7 @@ public interface MongoOperations {
/** /**
* Returns the document with the given id from the given collection mapped onto the given target class. * Returns the document with the given id from the given collection mapped onto the given target class.
* *
* @param id the id of the document to return * @param id the id of the document to return
* @param entityClass the type to convert the document to * @param entityClass the type to convert the document to
* @param collectionName the collection to query for the document * @param collectionName the collection to query for the document
@ -631,7 +636,7 @@ public interface MongoOperations {
/** /**
* Triggers <a href="http://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify * Triggers <a href="http://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify
* <a/> to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query}. * <a/> to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query}.
* *
* @param query the {@link Query} class that specifies the {@link Criteria} used to find a record and also an optional * @param query the {@link Query} class that specifies the {@link Criteria} used to find a record and also an optional
* fields specification. * fields specification.
* @param update the {@link Update} to apply on matching documents. * @param update the {@link Update} to apply on matching documents.
@ -643,7 +648,7 @@ public interface MongoOperations {
/** /**
* Triggers <a href="http://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify * Triggers <a href="http://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify
* <a/> to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query}. * <a/> to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query}.
* *
* @param query the {@link Query} class that specifies the {@link Criteria} used to find a record and also an optional * @param query the {@link Query} class that specifies the {@link Criteria} used to find a record and also an optional
* fields specification. * fields specification.
* @param update the {@link Update} to apply on matching documents. * @param update the {@link Update} to apply on matching documents.
@ -657,7 +662,7 @@ public interface MongoOperations {
* Triggers <a href="http://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify * Triggers <a href="http://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify
* <a/> to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query} taking * <a/> to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query} taking
* {@link FindAndModifyOptions} into account. * {@link FindAndModifyOptions} into account.
* *
* @param query the {@link Query} class that specifies the {@link Criteria} used to find a record and also an optional * @param query the {@link Query} class that specifies the {@link Criteria} used to find a record and also an optional
* fields specification. * fields specification.
* @param update the {@link Update} to apply on matching documents. * @param update the {@link Update} to apply on matching documents.
@ -671,7 +676,7 @@ public interface MongoOperations {
* Triggers <a href="http://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify * Triggers <a href="http://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/">findAndModify
* <a/> to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query} taking * <a/> to apply provided {@link Update} on documents matching {@link Criteria} of given {@link Query} taking
* {@link FindAndModifyOptions} into account. * {@link FindAndModifyOptions} into account.
* *
* @param query the {@link Query} class that specifies the {@link Criteria} used to find a record and also an optional * @param query the {@link Query} class that specifies the {@link Criteria} used to find a record and also an optional
* fields specification. * fields specification.
* @param update the {@link Update} to apply on matching documents. * @param update the {@link Update} to apply on matching documents.
@ -692,7 +697,7 @@ public interface MongoOperations {
* <p/> * <p/>
* The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more * The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more
* feature rich {@link Query}. * feature rich {@link Query}.
* *
* @param query the query class that specifies the criteria used to find a record and also an optional fields * @param query the query class that specifies the criteria used to find a record and also an optional fields
* specification * specification
* @param entityClass the parameterized type of the returned list. * @param entityClass the parameterized type of the returned list.
@ -709,7 +714,7 @@ public interface MongoOperations {
* <p/> * <p/>
* The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more * The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more
* feature rich {@link Query}. * feature rich {@link Query}.
* *
* @param query the query class that specifies the criteria used to find a record and also an optional fields * @param query the query class that specifies the criteria used to find a record and also an optional fields
* specification * specification
* @param entityClass the parameterized type of the returned list. * @param entityClass the parameterized type of the returned list.
@ -720,7 +725,7 @@ public interface MongoOperations {
/** /**
* Returns the number of documents for the given {@link Query} by querying the collection of the given entity class. * Returns the number of documents for the given {@link Query} by querying the collection of the given entity class.
* *
* @param query * @param query
* @param entityClass must not be {@literal null}. * @param entityClass must not be {@literal null}.
* @return * @return
@ -730,8 +735,8 @@ public interface MongoOperations {
/** /**
* Returns the number of documents for the given {@link Query} querying the given collection. The given {@link Query} * 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 * 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 query
* @param collectionName must not be {@literal null} or empty. * @param collectionName must not be {@literal null} or empty.
* @return * @return
@ -742,7 +747,7 @@ public interface MongoOperations {
/** /**
* Returns the number of documents for the given {@link Query} by querying the given collection using the given entity * Returns the number of documents for the given {@link Query} by querying the given collection using the given entity
* class to map the given {@link Query}. * class to map the given {@link Query}.
* *
* @param query * @param query
* @param entityClass must not be {@literal null}. * @param entityClass must not be {@literal null}.
* @param collectionName must not be {@literal null} or empty. * @param collectionName must not be {@literal null} or empty.
@ -763,7 +768,7 @@ public interface MongoOperations {
* <p/> * <p/>
* <p/> * <p/>
* Insert is used to initially store the object into the database. To update an existing object use the save method. * 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. * @param objectToSave the object to store in the collection.
*/ */
void insert(Object objectToSave); void insert(Object objectToSave);
@ -775,7 +780,7 @@ public interface MongoOperations {
* configured otherwise, an instance of MappingMongoConverter will be used. * configured otherwise, an instance of MappingMongoConverter will be used.
* <p/> * <p/>
* Insert is used to initially store the object into the database. To update an existing object use the save method. * 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 * @param objectToSave the object to store in the collection
* @param collectionName name of the collection to store the object in * @param collectionName name of the collection to store the object in
*/ */
@ -783,7 +788,7 @@ public interface MongoOperations {
/** /**
* Insert a Collection of objects into a collection in a single batch write to the database. * Insert a Collection of objects into a collection in a single batch write to the database.
* *
* @param batchToSave the list of objects to save. * @param batchToSave the list of objects to save.
* @param entityClass class that determines the collection to use * @param entityClass class that determines the collection to use
*/ */
@ -791,7 +796,7 @@ public interface MongoOperations {
/** /**
* Insert a list of objects into the specified collection in a single batch write to the database. * Insert a list of objects into the specified collection in a single batch write to the database.
* *
* @param batchToSave the list of objects to save. * @param batchToSave the list of objects to save.
* @param collectionName name of the collection to store the object in * @param collectionName name of the collection to store the object in
*/ */
@ -800,7 +805,7 @@ public interface MongoOperations {
/** /**
* Insert a mixed Collection of objects into a database collection determining the collection name to use based on the * Insert a mixed Collection of objects into a database collection determining the collection name to use based on the
* class. * class.
* *
* @param collectionToSave the list of objects to save. * @param collectionToSave the list of objects to save.
*/ */
void insertAll(Collection<? extends Object> objectsToSave); void insertAll(Collection<? extends Object> objectsToSave);
@ -817,7 +822,7 @@ public interface MongoOperations {
* property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See * property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See
* <a href="http://docs.spring.io/spring/docs/current/spring-framework-reference/html/validation.html#core-convert" > * <a href="http://docs.spring.io/spring/docs/current/spring-framework-reference/html/validation.html#core-convert" >
* Spring's Type Conversion"</a> for more details. * Spring's Type Conversion"</a> for more details.
* *
* @param objectToSave the object to store in the collection * @param objectToSave the object to store in the collection
*/ */
void save(Object objectToSave); void save(Object objectToSave);
@ -834,7 +839,7 @@ public interface MongoOperations {
* property type will be handled by Spring's BeanWrapper class that leverages Type Cobnversion API. See <a * property type will be handled by Spring's BeanWrapper class that leverages Type Cobnversion API. See <a
* http://docs.spring.io/spring/docs/current/spring-framework-reference/html/validation.html#core-convert">Spring's * http://docs.spring.io/spring/docs/current/spring-framework-reference/html/validation.html#core-convert">Spring's
* Type Conversion"</a> for more details. * Type Conversion"</a> for more details.
* *
* @param objectToSave the object to store in the collection * @param objectToSave the object to store in the collection
* @param collectionName name of the collection to store the object in * @param collectionName name of the collection to store the object in
*/ */
@ -843,7 +848,7 @@ public interface MongoOperations {
/** /**
* Performs an upsert. If no document is found that matches the query, a new document is created and inserted by * 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.
* *
* @param query the query document that specifies the criteria used to select a record to be upserted * @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 update the update document that contains the updated object or $ operators to manipulate the existing object
* @param entityClass class that determines the collection to use * @param entityClass class that determines the collection to use
@ -853,8 +858,10 @@ public interface MongoOperations {
/** /**
* Performs an upsert. If no document is found that matches the query, a new document is created and inserted by * 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. <br />
* * <strong>NOTE:</strong> 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 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 * @param update the update document that contains the updated object or $ operators to manipulate the existing
* object. * 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 * 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.
* *
* @param query the query document that specifies the criteria used to select a record to be upserted * @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 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 * @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 * Updates the first object that is found in the collection of the entity class that matches the query document with
* the provided update document. * the provided update document.
* *
* @param query the query document that specifies the criteria used to select a record to be updated * @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 * @param update the update document that contains the updated object or $ operators to manipulate the existing
* object. * 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 * 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. <br />
* * <strong>NOTE:</strong> 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 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 * @param update the update document that contains the updated object or $ operators to manipulate the existing
* object. * 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 * 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.
* *
* @param query the query document that specifies the criteria used to select a record to be updated * @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 * @param update the update document that contains the updated object or $ operators to manipulate the existing
* object. * 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 * Updates all objects that are found in the collection for the entity class that matches the query document criteria
* with the provided updated document. * with the provided updated document.
* *
* @param query the query document that specifies the criteria used to select a record to be updated * @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 * @param update the update document that contains the updated object or $ operators to manipulate the existing
* object. * 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 * Updates all objects that are found in the specified collection that matches the query document criteria with the
* provided updated document. * provided updated document. <br />
* * <strong>NOTE:</strong> 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 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 * @param update the update document that contains the updated object or $ operators to manipulate the existing
* object. * 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 * Updates all objects that are found in the collection for the entity class that matches the query document criteria
* with the provided updated document. * with the provided updated document.
* *
* @param query the query document that specifies the criteria used to select a record to be updated * @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 * @param update the update document that contains the updated object or $ operators to manipulate the existing
* object. * object.
@ -951,14 +962,14 @@ public interface MongoOperations {
/** /**
* Remove the given object from the collection by id. * Remove the given object from the collection by id.
* *
* @param object * @param object
*/ */
WriteResult remove(Object object); WriteResult remove(Object object);
/** /**
* Removes the given object from the given collection. * Removes the given object from the given collection.
* *
* @param object * @param object
* @param collection must not be {@literal null} or empty. * @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 * 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. * 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 query
* @param entityClass * @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 * 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. * 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 query
* @param entityClass * @param entityClass
* @param collectionName * @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 * 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. <br />
* * <strong>NOTE:</strong> 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 query the query document that specifies the criteria used to remove a record
* @param collectionName name of the collection where the objects will removed * @param collectionName name of the collection where the objects will removed
*/ */
WriteResult remove(Query query, String collectionName); WriteResult 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. <br />
* * <strong>NOTE:</strong> Any additional support for field mapping is not available due to the lack of domain type
* @param query * information. Use {@link #findAllAndRemove(Query, Class, String)} to get full type specific support.
* @param collectionName *
* @param query must not be {@literal null}.
* @param collectionName must not be {@literal null}.
* @return * @return
* @since 1.5 * @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. * Returns and removes all documents matching the given query form the collection used to store the entityClass.
* *
* @param query * @param query
* @param entityClass * @param entityClass
* @return * @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 * 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 * store the entityClass. The Class parameter is also used to help convert the Id of the object if it is present in
* the query. * the query.
* *
* @param query * @param query
* @param entityClass * @param entityClass
* @param collectionName * @param collectionName
@ -1027,7 +1042,7 @@ public interface MongoOperations {
/** /**
* Returns the underlying {@link MongoConverter}. * Returns the underlying {@link MongoConverter}.
* *
* @return * @return
*/ */
MongoConverter getConverter(); MongoConverter getConverter();

Loading…
Cancel
Save