126
126
127
127
/**
128
128
* Primary implementation of {@link MongoOperations}.
129
- *
129
+ *
130
130
* @author Thomas Risberg
131
131
* @author Graeme Rocher
132
132
* @author Mark Pollack
@@ -177,7 +177,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware {
177
177
178
178
/**
179
179
* Constructor used for a basic template configuration
180
- *
180
+ *
181
181
* @param mongo must not be {@literal null}.
182
182
* @param databaseName must not be {@literal null} or empty.
183
183
*/
@@ -188,7 +188,7 @@ public MongoTemplate(Mongo mongo, String databaseName) {
188
188
/**
189
189
* Constructor used for a template configuration with user credentials in the form of
190
190
* {@link org.springframework.data.authentication.UserCredentials}
191
- *
191
+ *
192
192
* @param mongo must not be {@literal null}.
193
193
* @param databaseName must not be {@literal null} or empty.
194
194
* @param userCredentials
@@ -199,7 +199,7 @@ public MongoTemplate(Mongo mongo, String databaseName, UserCredentials userCrede
199
199
200
200
/**
201
201
* Constructor used for a basic template configuration.
202
- *
202
+ *
203
203
* @param mongoDbFactory must not be {@literal null}.
204
204
*/
205
205
public MongoTemplate (MongoDbFactory mongoDbFactory ) {
@@ -208,7 +208,7 @@ public MongoTemplate(MongoDbFactory mongoDbFactory) {
208
208
209
209
/**
210
210
* Constructor used for a basic template configuration.
211
- *
211
+ *
212
212
* @param mongoDbFactory must not be {@literal null}.
213
213
* @param mongoConverter
214
214
*/
@@ -237,7 +237,7 @@ public MongoTemplate(MongoDbFactory mongoDbFactory, MongoConverter mongoConverte
237
237
/**
238
238
* Configures the {@link WriteResultChecking} to be used with the template. Setting {@literal null} will reset the
239
239
* default of {@value #DEFAULT_WRITE_RESULT_CHECKING}.
240
- *
240
+ *
241
241
* @param resultChecking
242
242
*/
243
243
public void setWriteResultChecking (WriteResultChecking resultChecking ) {
@@ -248,7 +248,7 @@ public void setWriteResultChecking(WriteResultChecking resultChecking) {
248
248
* Configures the {@link WriteConcern} to be used with the template. If none is configured the {@link WriteConcern}
249
249
* configured on the {@link MongoDbFactory} will apply. If you configured a {@link Mongo} instance no
250
250
* {@link WriteConcern} will be used.
251
- *
251
+ *
252
252
* @param writeConcern
253
253
*/
254
254
public void setWriteConcern (WriteConcern writeConcern ) {
@@ -257,7 +257,7 @@ public void setWriteConcern(WriteConcern writeConcern) {
257
257
258
258
/**
259
259
* Configures the {@link WriteConcernResolver} to be used with the template.
260
- *
260
+ *
261
261
* @param writeConcernResolver
262
262
*/
263
263
public void setWriteConcernResolver (WriteConcernResolver writeConcernResolver ) {
@@ -267,7 +267,7 @@ public void setWriteConcernResolver(WriteConcernResolver writeConcernResolver) {
267
267
/**
268
268
* Used by @{link {@link #prepareCollection(DBCollection)} to set the {@link ReadPreference} before any operations are
269
269
* performed.
270
- *
270
+ *
271
271
* @param readPreference
272
272
*/
273
273
public void setReadPreference (ReadPreference readPreference ) {
@@ -294,7 +294,7 @@ public void setApplicationContext(ApplicationContext applicationContext) throws
294
294
* they were registered for the current {@link MappingContext}. If no creator for the current {@link MappingContext}
295
295
* can be found we manually add the internally created one as {@link ApplicationListener} to make sure indexes get
296
296
* created appropriately for entity types persisted through this {@link MongoTemplate} instance.
297
- *
297
+ *
298
298
* @param context must not be {@literal null}.
299
299
*/
300
300
private void prepareIndexCreator (ApplicationContext context ) {
@@ -314,15 +314,15 @@ private void prepareIndexCreator(ApplicationContext context) {
314
314
}
315
315
316
316
/**
317
- * Returns the default {@link org.springframework.data.mongodb.core.core. convert.MongoConverter}.
318
- *
317
+ * Returns the default {@link org.springframework.data.mongodb.core.convert.MongoConverter}.
318
+ *
319
319
* @return
320
320
*/
321
321
public MongoConverter getConverter () {
322
322
return this .mongoConverter ;
323
323
}
324
324
325
- /*
325
+ /*
326
326
* (non-Javadoc)
327
327
* @see org.springframework.data.mongodb.core.MongoOperations#executeAsStream(org.springframework.data.mongodb.core.query.Query, java.lang.Class)
328
328
*/
@@ -332,7 +332,7 @@ public <T> CloseableIterator<T> stream(final Query query, final Class<T> entityT
332
332
return stream (query , entityType , determineCollectionName (entityType ));
333
333
}
334
334
335
- /*
335
+ /*
336
336
* (non-Javadoc)
337
337
* @see org.springframework.data.mongodb.core.MongoOperations#stream(org.springframework.data.mongodb.core.query.Query, java.lang.Class, java.lang.String)
338
338
*/
@@ -428,7 +428,7 @@ public void executeQuery(Query query, String collectionName, DocumentCallbackHan
428
428
/**
429
429
* Execute a MongoDB query and iterate over the query results on a per-document basis with a
430
430
* {@link DocumentCallbackHandler} using the provided CursorPreparer.
431
- *
431
+ *
432
432
* @param query the query class that specifies the criteria used to find a record and also an optional fields
433
433
* specification, must not be {@literal null}.
434
434
* @param collectionName name of the collection to retrieve the objects from
@@ -699,7 +699,7 @@ public <T> GeoResults<T> geoNear(NearQuery near, Class<T> entityClass, String co
699
699
/*
700
700
* As MongoDB currently (2.4.4) doesn't support the skipping of elements in near queries
701
701
* we skip the elements ourselves to avoid at least the document 2 object mapping overhead.
702
- *
702
+ *
703
703
* @see https://jira.mongodb.org/browse/SERVER-3925
704
704
*/
705
705
if (index >= elementsToSkip ) {
@@ -804,7 +804,7 @@ protected void ensureNotIterable(Object o) {
804
804
/**
805
805
* Prepare the collection before any processing is done using it. This allows a convenient way to apply settings like
806
806
* slaveOk() etc. Can be overridden in sub-classes.
807
- *
807
+ *
808
808
* @param collection
809
809
*/
810
810
protected void prepareCollection (DBCollection collection ) {
@@ -818,7 +818,7 @@ protected void prepareCollection(DBCollection collection) {
818
818
* settings in sub-classes. <br />
819
819
* In case of using MongoDB Java driver version 3 the returned {@link WriteConcern} will be defaulted to
820
820
* {@link WriteConcern#ACKNOWLEDGED} when {@link WriteResultChecking} is set to {@link WriteResultChecking#EXCEPTION}.
821
- *
821
+ *
822
822
* @param writeConcern any WriteConcern already configured or null
823
823
* @return The prepared WriteConcern or null
824
824
*/
@@ -1228,7 +1228,7 @@ public WriteResult remove(Object object, String collection) {
1228
1228
/**
1229
1229
* Returns {@link Entry} containing the field name of the id property as {@link Entry#getKey()} and the {@link Id}s
1230
1230
* property value as its {@link Entry#getValue()}.
1231
- *
1231
+ *
1232
1232
* @param object
1233
1233
* @return
1234
1234
*/
@@ -1255,7 +1255,7 @@ private Entry<String, Object> extractIdPropertyAndValue(Object object) {
1255
1255
1256
1256
/**
1257
1257
* Returns a {@link Query} for the given entity by its id.
1258
- *
1258
+ *
1259
1259
* @param object must not be {@literal null}.
1260
1260
* @return
1261
1261
*/
@@ -1267,7 +1267,7 @@ private Query getIdQueryFor(Object object) {
1267
1267
1268
1268
/**
1269
1269
* Returns a {@link Query} for the given entities by their ids.
1270
- *
1270
+ *
1271
1271
* @param objects must not be {@literal null} or {@literal empty}.
1272
1272
* @return
1273
1273
*/
@@ -1538,7 +1538,7 @@ public <T> List<T> findAllAndRemove(Query query, Class<T> entityClass, String co
1538
1538
* Retrieve and remove all documents matching the given {@code query} by calling {@link #find(Query, Class, String)}
1539
1539
* and {@link #remove(Query, Class, String)}, whereas the {@link Query} for {@link #remove(Query, Class, String)} is
1540
1540
* constructed out of the find result.
1541
- *
1541
+ *
1542
1542
* @param collectionName
1543
1543
* @param query
1544
1544
* @param entityClass
@@ -1578,7 +1578,7 @@ protected <O> AggregationResults<O> aggregate(Aggregation aggregation, String co
1578
1578
1579
1579
/**
1580
1580
* Returns the potentially mapped results of the given {@commandResult} contained some.
1581
- *
1581
+ *
1582
1582
* @param outputType
1583
1583
* @param commandResult
1584
1584
* @return
@@ -1690,7 +1690,7 @@ protected <T> void maybeEmitEvent(MongoMappingEvent<T> event) {
1690
1690
1691
1691
/**
1692
1692
* Create the specified collection using the provided options
1693
- *
1693
+ *
1694
1694
* @param collectionName
1695
1695
* @param collectionOptions
1696
1696
* @return the collection that was created
@@ -1711,7 +1711,7 @@ public DBCollection doInDB(DB db) throws MongoException, DataAccessException {
1711
1711
/**
1712
1712
* Map the results of an ad-hoc query on the default MongoDB collection to an object using the template's converter.
1713
1713
* The query document is specified as a standard {@link DBObject} and so is the fields specification.
1714
- *
1714
+ *
1715
1715
* @param collectionName name of the collection to retrieve the objects from.
1716
1716
* @param query the query document that specifies the criteria used to find a record.
1717
1717
* @param fields the document that specifies the fields to be returned.
@@ -1736,7 +1736,7 @@ protected <T> T doFindOne(String collectionName, DBObject query, DBObject fields
1736
1736
/**
1737
1737
* Map the results of an ad-hoc query on the default MongoDB collection to a List using the template's converter. The
1738
1738
* query document is 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
@@ -1752,7 +1752,7 @@ protected <T> List<T> doFind(String collectionName, DBObject query, DBObject fie
1752
1752
* Map the results of an ad-hoc query on the default MongoDB collection to a List of the specified type. The object is
1753
1753
* converted from the MongoDB native representation using an instance of {@see MongoConverter}. The query document is
1754
1754
* specified as a standard DBObject and so is the fields specification.
1755
- *
1755
+ *
1756
1756
* @param collectionName name of the collection to retrieve the objects from.
1757
1757
* @param query the query document that specifies the criteria used to find a record.
1758
1758
* @param fields the document that specifies the fields to be returned.
@@ -1805,7 +1805,7 @@ protected DBObject convertToDbObject(CollectionOptions collectionOptions) {
1805
1805
* The first document that matches the query is returned and also removed from the collection in the database.
1806
1806
* <p/>
1807
1807
* The query document is specified as a standard DBObject and so is the fields specification.
1808
- *
1808
+ *
1809
1809
* @param collectionName name of the collection to retrieve the objects from
1810
1810
* @param query the query document that specifies the criteria used to find a record
1811
1811
* @param entityClass the parameterized type of the returned list.
@@ -1856,7 +1856,7 @@ protected <T> T doFindAndModify(String collectionName, DBObject query, DBObject
1856
1856
1857
1857
/**
1858
1858
* Populates the id property of the saved object, if it's not set already.
1859
- *
1859
+ *
1860
1860
* @param savedObject
1861
1861
* @param id
1862
1862
*/
@@ -1906,7 +1906,7 @@ private DBCollection getAndPrepareCollection(DB db, String collectionName) {
1906
1906
* <li>Execute the given {@link ConnectionCallback} for a {@link DBObject}.</li>
1907
1907
* <li>Apply the given {@link DbObjectCallback} to each of the {@link DBObject}s to obtain the result.</li>
1908
1908
* <ol>
1909
- *
1909
+ *
1910
1910
* @param <T>
1911
1911
* @param collectionCallback the callback to retrieve the {@link DBObject} with
1912
1912
* @param objectCallback the {@link DbObjectCallback} to transform {@link DBObject}s into the actual domain type
@@ -1935,7 +1935,7 @@ private <T> T executeFindOneInternal(CollectionCallback<DBObject> collectionCall
1935
1935
* <li>Iterate over the {@link DBCursor} and applies the given {@link DbObjectCallback} to each of the
1936
1936
* {@link DBObject}s collecting the actual result {@link List}.</li>
1937
1937
* <ol>
1938
- *
1938
+ *
1939
1939
* @param <T>
1940
1940
* @param collectionCallback the callback to retrieve the {@link DBCursor} with
1941
1941
* @param preparer the {@link CursorPreparer} to potentially modify the {@link DBCursor} before ireating over it
@@ -2042,7 +2042,7 @@ String determineCollectionName(Class<?> entityClass) {
2042
2042
2043
2043
/**
2044
2044
* Handles {@link WriteResult} errors based on the configured {@link WriteResultChecking}.
2045
- *
2045
+ *
2046
2046
* @param writeResult
2047
2047
* @param query
2048
2048
* @param operation
@@ -2086,7 +2086,7 @@ protected void handleAnyWriteResultErrors(WriteResult writeResult, DBObject quer
2086
2086
/**
2087
2087
* Inspects the given {@link CommandResult} for erros and potentially throws an
2088
2088
* {@link InvalidDataAccessApiUsageException} for that error.
2089
- *
2089
+ *
2090
2090
* @param result must not be {@literal null}.
2091
2091
* @param source must not be {@literal null}.
2092
2092
*/
@@ -2124,7 +2124,7 @@ private DBObject getMappedSortObject(Query query, Class<?> type) {
2124
2124
/**
2125
2125
* Tries to convert the given {@link RuntimeException} into a {@link DataAccessException} but returns the original
2126
2126
* exception if the conversation failed. Thus allows safe re-throwing of the return value.
2127
- *
2127
+ *
2128
2128
* @param ex the exception to translate
2129
2129
* @param exceptionTranslator the {@link PersistenceExceptionTranslator} to be used for translation
2130
2130
* @return
@@ -2162,7 +2162,7 @@ private static List<Object> consolidateIdentifiers(List<ObjectId> ids, List<DBOb
2162
2162
/**
2163
2163
* Simple {@link CollectionCallback} that takes a query {@link DBObject} plus an optional fields specification
2164
2164
* {@link DBObject} and executes that against the {@link DBCollection}.
2165
- *
2165
+ *
2166
2166
* @author Oliver Gierke
2167
2167
* @author Thomas Risberg
2168
2168
*/
@@ -2196,7 +2196,7 @@ public DBObject doInCollection(DBCollection collection) throws MongoException, D
2196
2196
/**
2197
2197
* Simple {@link CollectionCallback} that takes a query {@link DBObject} plus an optional fields specification
2198
2198
* {@link DBObject} and executes that against the {@link DBCollection}.
2199
- *
2199
+ *
2200
2200
* @author Oliver Gierke
2201
2201
* @author Thomas Risberg
2202
2202
*/
@@ -2227,7 +2227,7 @@ public DBCursor doInCollection(DBCollection collection) throws MongoException, D
2227
2227
/**
2228
2228
* Simple {@link CollectionCallback} that takes a query {@link DBObject} plus an optional fields specification
2229
2229
* {@link DBObject} and executes that against the {@link DBCollection}.
2230
- *
2230
+ *
2231
2231
* @author Thomas Risberg
2232
2232
*/
2233
2233
private static class FindAndRemoveCallback implements CollectionCallback <DBObject > {
@@ -2272,7 +2272,7 @@ public DBObject doInCollection(DBCollection collection) throws MongoException, D
2272
2272
2273
2273
/**
2274
2274
* Simple internal callback to allow operations on a {@link DBObject}.
2275
- *
2275
+ *
2276
2276
* @author Oliver Gierke
2277
2277
* @author Thomas Darimont
2278
2278
*/
@@ -2285,7 +2285,7 @@ interface DbObjectCallback<T> {
2285
2285
/**
2286
2286
* Simple {@link DbObjectCallback} that will transform {@link DBObject} into the given target type using the given
2287
2287
* {@link MongoReader}.
2288
- *
2288
+ *
2289
2289
* @author Oliver Gierke
2290
2290
* @author Christoph Strobl
2291
2291
*/
@@ -2431,7 +2431,7 @@ public DBCursor prepare(DBCursor cursor) {
2431
2431
/**
2432
2432
* {@link DbObjectCallback} that assumes a {@link GeoResult} to be created, delegates actual content unmarshalling to
2433
2433
* a delegate and creates a {@link GeoResult} from the result.
2434
- *
2434
+ *
2435
2435
* @author Oliver Gierke
2436
2436
*/
2437
2437
static class GeoNearResultDbObjectCallback <T > implements DbObjectCallback <GeoResult <T >> {
@@ -2442,7 +2442,7 @@ static class GeoNearResultDbObjectCallback<T> implements DbObjectCallback<GeoRes
2442
2442
/**
2443
2443
* Creates a new {@link GeoNearResultDbObjectCallback} using the given {@link DbObjectCallback} delegate for
2444
2444
* {@link GeoResult} content unmarshalling.
2445
- *
2445
+ *
2446
2446
* @param delegate must not be {@literal null}.
2447
2447
*/
2448
2448
public GeoNearResultDbObjectCallback (DbObjectCallback <T > delegate , Metric metric ) {
@@ -2464,7 +2464,7 @@ public GeoResult<T> doWith(DBObject object) {
2464
2464
2465
2465
/**
2466
2466
* A {@link CloseableIterator} that is backed by a MongoDB {@link Cursor}.
2467
- *
2467
+ *
2468
2468
* @since 1.7
2469
2469
* @author Thomas Darimont
2470
2470
*/
@@ -2476,7 +2476,7 @@ static class CloseableIterableCursorAdapter<T> implements CloseableIterator<T> {
2476
2476
2477
2477
/**
2478
2478
* Creates a new {@link CloseableIterableCursorAdapter} backed by the given {@link Cursor}.
2479
- *
2479
+ *
2480
2480
* @param cursor
2481
2481
* @param exceptionTranslator
2482
2482
* @param objectReadCallback
0 commit comments