Skip to content

Commit fbcd4ba

Browse files
nikosmp911de
authored andcommitted
DATAMONGO-1476 - Consistently use specified collection name in MongoTemplate.stream().
We now use the specified argument name instead of DBCollection.getName() when invoking ReadDbObjectCallback. Original pull request: #382.
1 parent 760d7d6 commit fbcd4ba

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
* @author Chuong Ngo
139139
* @author Christoph Strobl
140140
* @author Doménique Tilleuil
141+
* @author Niko Schmuck
141142
*/
142143
@SuppressWarnings("deprecation")
143144
public class MongoTemplate implements MongoOperations, ApplicationContextAware {
@@ -334,7 +335,7 @@ public <T> CloseableIterator<T> stream(final Query query, final Class<T> entityT
334335
* @see org.springframework.data.mongodb.core.MongoOperations#stream(org.springframework.data.mongodb.core.query.Query, java.lang.Class, java.lang.String)
335336
*/
336337
@Override
337-
public <T> CloseableIterator<T> stream(final Query query, final Class<T> entityType, String collectionName) {
338+
public <T> CloseableIterator<T> stream(final Query query, final Class<T> entityType, final String collectionName) {
338339

339340
Assert.notNull(query, "Query must not be null!");
340341
Assert.notNull(entityType, "Entity type must not be null!");
@@ -353,8 +354,7 @@ public CloseableIterator<T> doInCollection(DBCollection collection) throws Mongo
353354
DBCursor cursor = collection.find(mappedQuery, mappedFields);
354355
QueryCursorPreparer cursorPreparer = new QueryCursorPreparer(query, entityType);
355356

356-
ReadDbObjectCallback<T> readCallback = new ReadDbObjectCallback<T>(mongoConverter, entityType,
357-
collection.getName());
357+
ReadDbObjectCallback<T> readCallback = new ReadDbObjectCallback<T>(mongoConverter, entityType, collectionName);
358358

359359
return new CloseableIterableCursorAdapter<T>(cursorPreparer.prepare(cursor), exceptionTranslator, readCallback);
360360
}

0 commit comments

Comments
 (0)