125
125
126
126
/**
127
127
* Primary implementation of {@link MongoOperations}.
128
- *
128
+ *
129
129
* @author Thomas Risberg
130
130
* @author Graeme Rocher
131
131
* @author Mark Pollack
@@ -174,7 +174,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware {
174
174
175
175
/**
176
176
* Constructor used for a basic template configuration
177
- *
177
+ *
178
178
* @param mongo must not be {@literal null}.
179
179
* @param databaseName must not be {@literal null} or empty.
180
180
*/
@@ -185,7 +185,7 @@ public MongoTemplate(Mongo mongo, String databaseName) {
185
185
/**
186
186
* Constructor used for a template configuration with user credentials in the form of
187
187
* {@link org.springframework.data.authentication.UserCredentials}
188
- *
188
+ *
189
189
* @param mongo must not be {@literal null}.
190
190
* @param databaseName must not be {@literal null} or empty.
191
191
* @param userCredentials
@@ -196,7 +196,7 @@ public MongoTemplate(Mongo mongo, String databaseName, UserCredentials userCrede
196
196
197
197
/**
198
198
* Constructor used for a basic template configuration.
199
- *
199
+ *
200
200
* @param mongoDbFactory must not be {@literal null}.
201
201
*/
202
202
public MongoTemplate (MongoDbFactory mongoDbFactory ) {
@@ -205,7 +205,7 @@ public MongoTemplate(MongoDbFactory mongoDbFactory) {
205
205
206
206
/**
207
207
* Constructor used for a basic template configuration.
208
- *
208
+ *
209
209
* @param mongoDbFactory must not be {@literal null}.
210
210
* @param mongoConverter
211
211
*/
@@ -234,7 +234,7 @@ public MongoTemplate(MongoDbFactory mongoDbFactory, MongoConverter mongoConverte
234
234
/**
235
235
* Configures the {@link WriteResultChecking} to be used with the template. Setting {@literal null} will reset the
236
236
* default of {@value #DEFAULT_WRITE_RESULT_CHECKING}.
237
- *
237
+ *
238
238
* @param resultChecking
239
239
*/
240
240
public void setWriteResultChecking (WriteResultChecking resultChecking ) {
@@ -245,7 +245,7 @@ public void setWriteResultChecking(WriteResultChecking resultChecking) {
245
245
* Configures the {@link WriteConcern} to be used with the template. If none is configured the {@link WriteConcern}
246
246
* configured on the {@link MongoDbFactory} will apply. If you configured a {@link Mongo} instance no
247
247
* {@link WriteConcern} will be used.
248
- *
248
+ *
249
249
* @param writeConcern
250
250
*/
251
251
public void setWriteConcern (WriteConcern writeConcern ) {
@@ -254,7 +254,7 @@ public void setWriteConcern(WriteConcern writeConcern) {
254
254
255
255
/**
256
256
* Configures the {@link WriteConcernResolver} to be used with the template.
257
- *
257
+ *
258
258
* @param writeConcernResolver
259
259
*/
260
260
public void setWriteConcernResolver (WriteConcernResolver writeConcernResolver ) {
@@ -264,7 +264,7 @@ public void setWriteConcernResolver(WriteConcernResolver writeConcernResolver) {
264
264
/**
265
265
* Used by @{link {@link #prepareCollection(DBCollection)} to set the {@link ReadPreference} before any operations are
266
266
* performed.
267
- *
267
+ *
268
268
* @param readPreference
269
269
*/
270
270
public void setReadPreference (ReadPreference readPreference ) {
@@ -291,7 +291,7 @@ public void setApplicationContext(ApplicationContext applicationContext) throws
291
291
* they were registered for the current {@link MappingContext}. If no creator for the current {@link MappingContext}
292
292
* can be found we manually add the internally created one as {@link ApplicationListener} to make sure indexes get
293
293
* created appropriately for entity types persisted through this {@link MongoTemplate} instance.
294
- *
294
+ *
295
295
* @param context must not be {@literal null}.
296
296
*/
297
297
private void prepareIndexCreator (ApplicationContext context ) {
@@ -311,15 +311,15 @@ private void prepareIndexCreator(ApplicationContext context) {
311
311
}
312
312
313
313
/**
314
- * Returns the default {@link org.springframework.data.mongodb.core.core. convert.MongoConverter}.
315
- *
314
+ * Returns the default {@link org.springframework.data.mongodb.core.convert.MongoConverter}.
315
+ *
316
316
* @return
317
317
*/
318
318
public MongoConverter getConverter () {
319
319
return this .mongoConverter ;
320
320
}
321
321
322
- /*
322
+ /*
323
323
* (non-Javadoc)
324
324
* @see org.springframework.data.mongodb.core.MongoOperations#executeAsStream(org.springframework.data.mongodb.core.query.Query, java.lang.Class)
325
325
*/
@@ -412,7 +412,7 @@ public void executeQuery(Query query, String collectionName, DocumentCallbackHan
412
412
/**
413
413
* Execute a MongoDB query and iterate over the query results on a per-document basis with a
414
414
* {@link DocumentCallbackHandler} using the provided CursorPreparer.
415
- *
415
+ *
416
416
* @param query the query class that specifies the criteria used to find a record and also an optional fields
417
417
* specification, must not be {@literal null}.
418
418
* @param collectionName name of the collection to retrieve the objects from
@@ -683,7 +683,7 @@ public <T> GeoResults<T> geoNear(NearQuery near, Class<T> entityClass, String co
683
683
/*
684
684
* As MongoDB currently (2.4.4) doesn't support the skipping of elements in near queries
685
685
* we skip the elements ourselves to avoid at least the document 2 object mapping overhead.
686
- *
686
+ *
687
687
* @see https://jira.mongodb.org/browse/SERVER-3925
688
688
*/
689
689
if (index >= elementsToSkip ) {
@@ -788,7 +788,7 @@ protected void ensureNotIterable(Object o) {
788
788
/**
789
789
* Prepare the collection before any processing is done using it. This allows a convenient way to apply settings like
790
790
* slaveOk() etc. Can be overridden in sub-classes.
791
- *
791
+ *
792
792
* @param collection
793
793
*/
794
794
protected void prepareCollection (DBCollection collection ) {
@@ -802,7 +802,7 @@ protected void prepareCollection(DBCollection collection) {
802
802
* settings in sub-classes. <br />
803
803
* In case of using MongoDB Java driver version 3 the returned {@link WriteConcern} will be defaulted to
804
804
* {@link WriteConcern#ACKNOWLEDGED} when {@link WriteResultChecking} is set to {@link WriteResultChecking#EXCEPTION}.
805
- *
805
+ *
806
806
* @param writeConcern any WriteConcern already configured or null
807
807
* @return The prepared WriteConcern or null
808
808
*/
@@ -1212,7 +1212,7 @@ public WriteResult remove(Object object, String collection) {
1212
1212
/**
1213
1213
* Returns {@link Entry} containing the field name of the id property as {@link Entry#getKey()} and the {@link Id}s
1214
1214
* property value as its {@link Entry#getValue()}.
1215
- *
1215
+ *
1216
1216
* @param object
1217
1217
* @return
1218
1218
*/
@@ -1239,7 +1239,7 @@ private Entry<String, Object> extractIdPropertyAndValue(Object object) {
1239
1239
1240
1240
/**
1241
1241
* Returns a {@link Query} for the given entity by its id.
1242
- *
1242
+ *
1243
1243
* @param object must not be {@literal null}.
1244
1244
* @return
1245
1245
*/
@@ -1251,7 +1251,7 @@ private Query getIdQueryFor(Object object) {
1251
1251
1252
1252
/**
1253
1253
* Returns a {@link Query} for the given entities by their ids.
1254
- *
1254
+ *
1255
1255
* @param objects must not be {@literal null} or {@literal empty}.
1256
1256
* @return
1257
1257
*/
@@ -1522,7 +1522,7 @@ public <T> List<T> findAllAndRemove(Query query, Class<T> entityClass, String co
1522
1522
* Retrieve and remove all documents matching the given {@code query} by calling {@link #find(Query, Class, String)}
1523
1523
* and {@link #remove(Query, Class, String)}, whereas the {@link Query} for {@link #remove(Query, Class, String)} is
1524
1524
* constructed out of the find result.
1525
- *
1525
+ *
1526
1526
* @param collectionName
1527
1527
* @param query
1528
1528
* @param entityClass
@@ -1562,7 +1562,7 @@ protected <O> AggregationResults<O> aggregate(Aggregation aggregation, String co
1562
1562
1563
1563
/**
1564
1564
* Returns the potentially mapped results of the given {@commandResult} contained some.
1565
- *
1565
+ *
1566
1566
* @param outputType
1567
1567
* @param commandResult
1568
1568
* @return
@@ -1674,7 +1674,7 @@ protected <T> void maybeEmitEvent(MongoMappingEvent<T> event) {
1674
1674
1675
1675
/**
1676
1676
* Create the specified collection using the provided options
1677
- *
1677
+ *
1678
1678
* @param collectionName
1679
1679
* @param collectionOptions
1680
1680
* @return the collection that was created
@@ -1695,7 +1695,7 @@ public DBCollection doInDB(DB db) throws MongoException, DataAccessException {
1695
1695
/**
1696
1696
* Map the results of an ad-hoc query on the default MongoDB collection to an object using the template's converter.
1697
1697
* The query document is specified as a standard {@link DBObject} and so is the fields specification.
1698
- *
1698
+ *
1699
1699
* @param collectionName name of the collection to retrieve the objects from.
1700
1700
* @param query the query document that specifies the criteria used to find a record.
1701
1701
* @param fields the document that specifies the fields to be returned.
@@ -1720,7 +1720,7 @@ protected <T> T doFindOne(String collectionName, DBObject query, DBObject fields
1720
1720
/**
1721
1721
* Map the results of an ad-hoc query on the default MongoDB collection to a List using the template's converter. The
1722
1722
* query document is specified as a standard DBObject and so is the fields specification.
1723
- *
1723
+ *
1724
1724
* @param collectionName name of the collection to retrieve the objects from
1725
1725
* @param query the query document that specifies the criteria used to find a record
1726
1726
* @param fields the document that specifies the fields to be returned
@@ -1736,7 +1736,7 @@ protected <T> List<T> doFind(String collectionName, DBObject query, DBObject fie
1736
1736
* Map the results of an ad-hoc query on the default MongoDB collection to a List of the specified type. The object is
1737
1737
* converted from the MongoDB native representation using an instance of {@see MongoConverter}. The query document is
1738
1738
* specified as a standard DBObject and so is the fields specification.
1739
- *
1739
+ *
1740
1740
* @param collectionName name of the collection to retrieve the objects from.
1741
1741
* @param query the query document that specifies the criteria used to find a record.
1742
1742
* @param fields the document that specifies the fields to be returned.
@@ -1789,7 +1789,7 @@ protected DBObject convertToDbObject(CollectionOptions collectionOptions) {
1789
1789
* The first document that matches the query is returned and also removed from the collection in the database.
1790
1790
* <p/>
1791
1791
* The query document is specified as a standard DBObject and so is the fields specification.
1792
- *
1792
+ *
1793
1793
* @param collectionName name of the collection to retrieve the objects from
1794
1794
* @param query the query document that specifies the criteria used to find a record
1795
1795
* @param entityClass the parameterized type of the returned list.
@@ -1840,7 +1840,7 @@ protected <T> T doFindAndModify(String collectionName, DBObject query, DBObject
1840
1840
1841
1841
/**
1842
1842
* Populates the id property of the saved object, if it's not set already.
1843
- *
1843
+ *
1844
1844
* @param savedObject
1845
1845
* @param id
1846
1846
*/
@@ -1890,7 +1890,7 @@ private DBCollection getAndPrepareCollection(DB db, String collectionName) {
1890
1890
* <li>Execute the given {@link ConnectionCallback} for a {@link DBObject}.</li>
1891
1891
* <li>Apply the given {@link DbObjectCallback} to each of the {@link DBObject}s to obtain the result.</li>
1892
1892
* <ol>
1893
- *
1893
+ *
1894
1894
* @param <T>
1895
1895
* @param collectionCallback the callback to retrieve the {@link DBObject} with
1896
1896
* @param objectCallback the {@link DbObjectCallback} to transform {@link DBObject}s into the actual domain type
@@ -1919,7 +1919,7 @@ private <T> T executeFindOneInternal(CollectionCallback<DBObject> collectionCall
1919
1919
* <li>Iterate over the {@link DBCursor} and applies the given {@link DbObjectCallback} to each of the
1920
1920
* {@link DBObject}s collecting the actual result {@link List}.</li>
1921
1921
* <ol>
1922
- *
1922
+ *
1923
1923
* @param <T>
1924
1924
* @param collectionCallback the callback to retrieve the {@link DBCursor} with
1925
1925
* @param preparer the {@link CursorPreparer} to potentially modify the {@link DBCursor} before ireating over it
@@ -2026,7 +2026,7 @@ String determineCollectionName(Class<?> entityClass) {
2026
2026
2027
2027
/**
2028
2028
* Handles {@link WriteResult} errors based on the configured {@link WriteResultChecking}.
2029
- *
2029
+ *
2030
2030
* @param writeResult
2031
2031
* @param query
2032
2032
* @param operation
@@ -2070,7 +2070,7 @@ protected void handleAnyWriteResultErrors(WriteResult writeResult, DBObject quer
2070
2070
/**
2071
2071
* Inspects the given {@link CommandResult} for erros and potentially throws an
2072
2072
* {@link InvalidDataAccessApiUsageException} for that error.
2073
- *
2073
+ *
2074
2074
* @param result must not be {@literal null}.
2075
2075
* @param source must not be {@literal null}.
2076
2076
*/
@@ -2108,7 +2108,7 @@ private DBObject getMappedSortObject(Query query, Class<?> type) {
2108
2108
/**
2109
2109
* Tries to convert the given {@link RuntimeException} into a {@link DataAccessException} but returns the original
2110
2110
* exception if the conversation failed. Thus allows safe re-throwing of the return value.
2111
- *
2111
+ *
2112
2112
* @param ex the exception to translate
2113
2113
* @param exceptionTranslator the {@link PersistenceExceptionTranslator} to be used for translation
2114
2114
* @return
@@ -2146,7 +2146,7 @@ private static List<Object> consolidateIdentifiers(List<ObjectId> ids, List<DBOb
2146
2146
/**
2147
2147
* Simple {@link CollectionCallback} that takes a query {@link DBObject} plus an optional fields specification
2148
2148
* {@link DBObject} and executes that against the {@link DBCollection}.
2149
- *
2149
+ *
2150
2150
* @author Oliver Gierke
2151
2151
* @author Thomas Risberg
2152
2152
*/
@@ -2180,7 +2180,7 @@ public DBObject doInCollection(DBCollection collection) throws MongoException, D
2180
2180
/**
2181
2181
* Simple {@link CollectionCallback} that takes a query {@link DBObject} plus an optional fields specification
2182
2182
* {@link DBObject} and executes that against the {@link DBCollection}.
2183
- *
2183
+ *
2184
2184
* @author Oliver Gierke
2185
2185
* @author Thomas Risberg
2186
2186
*/
@@ -2211,7 +2211,7 @@ public DBCursor doInCollection(DBCollection collection) throws MongoException, D
2211
2211
/**
2212
2212
* Simple {@link CollectionCallback} that takes a query {@link DBObject} plus an optional fields specification
2213
2213
* {@link DBObject} and executes that against the {@link DBCollection}.
2214
- *
2214
+ *
2215
2215
* @author Thomas Risberg
2216
2216
*/
2217
2217
private static class FindAndRemoveCallback implements CollectionCallback <DBObject > {
@@ -2256,7 +2256,7 @@ public DBObject doInCollection(DBCollection collection) throws MongoException, D
2256
2256
2257
2257
/**
2258
2258
* Simple internal callback to allow operations on a {@link DBObject}.
2259
- *
2259
+ *
2260
2260
* @author Oliver Gierke
2261
2261
* @author Thomas Darimont
2262
2262
*/
@@ -2269,7 +2269,7 @@ static interface DbObjectCallback<T> {
2269
2269
/**
2270
2270
* Simple {@link DbObjectCallback} that will transform {@link DBObject} into the given target type using the given
2271
2271
* {@link MongoReader}.
2272
- *
2272
+ *
2273
2273
* @author Oliver Gierke
2274
2274
* @author Christoph Strobl
2275
2275
*/
@@ -2389,7 +2389,7 @@ public DBCursor prepare(DBCursor cursor) {
2389
2389
/**
2390
2390
* {@link DbObjectCallback} that assumes a {@link GeoResult} to be created, delegates actual content unmarshalling to
2391
2391
* a delegate and creates a {@link GeoResult} from the result.
2392
- *
2392
+ *
2393
2393
* @author Oliver Gierke
2394
2394
*/
2395
2395
static class GeoNearResultDbObjectCallback <T > implements DbObjectCallback <GeoResult <T >> {
@@ -2400,7 +2400,7 @@ static class GeoNearResultDbObjectCallback<T> implements DbObjectCallback<GeoRes
2400
2400
/**
2401
2401
* Creates a new {@link GeoNearResultDbObjectCallback} using the given {@link DbObjectCallback} delegate for
2402
2402
* {@link GeoResult} content unmarshalling.
2403
- *
2403
+ *
2404
2404
* @param delegate must not be {@literal null}.
2405
2405
*/
2406
2406
public GeoNearResultDbObjectCallback (DbObjectCallback <T > delegate , Metric metric ) {
@@ -2422,7 +2422,7 @@ public GeoResult<T> doWith(DBObject object) {
2422
2422
2423
2423
/**
2424
2424
* A {@link CloseableIterator} that is backed by a MongoDB {@link Cursor}.
2425
- *
2425
+ *
2426
2426
* @since 1.7
2427
2427
* @author Thomas Darimont
2428
2428
*/
@@ -2434,7 +2434,7 @@ static class CloseableIterableCursorAdapter<T> implements CloseableIterator<T> {
2434
2434
2435
2435
/**
2436
2436
* Creates a new {@link CloseableIterableCursorAdapter} backed by the given {@link Cursor}.
2437
- *
2437
+ *
2438
2438
* @param cursor
2439
2439
* @param exceptionTranslator
2440
2440
* @param objectReadCallback
0 commit comments