[DATAMONGO-203] Add MongoOperations method that returns an Iterable<T> of converted domain objects as a result from a query Created: 19/Jul/11  Updated: 08/Jul/16  Resolved: 08/Jul/16

Status: Resolved
Project: Spring Data MongoDB
Component/s: Mapping / Conversion
Affects Version/s: 1.0 M3
Fix Version/s: None

Type: New Feature Priority: Minor
Reporter: Mark Pollack Assignee: Mark Paluch
Resolution: Complete Votes: 6
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Last updater: Mark Paluch


This will let one operate on the entities that were mapped from DBObject as they stream out of the DBCursor for processing a query result set.

Comment by Nicolas Ivering [ 19/Apr/13 ]

I'm interested in implementing this. I see a few possible approaches:

1. Add iterateXXX methods for each findXXX method. The iterateXXX methods would return an Iterator instead of a list. The iterator would load from DBCursor and deserialize object on every call to next(). Possibly you could instead return a class with implements both Iterator and Closeable, allowing the DBCursor to be closed.
2. Replace the return type List<T> of the findXXX methods with DataResult<T>. Interface DataResult would extend Iterator, Closeable and have a method asList() that would essentially do what the find method did originally, that is load the whole result into an ArrayList and return it. With this approach you don't have to add additional methods but it would break backwards compability.

What do you think?

Comment by Walery Strauch [ 01/Apr/15 ]

I believe this ticket is solved with this commit:


MongoOperation.stream(Query, Class<T>) does what is described in this issue.

Comment by Mark Paluch [ 08/Jul/16 ]

That's fixed with DATAMONGO-1165.

Generated at Sat Apr 20 07:11:41 UTC 2019 using JIRA 7.9.2#79002-sha1:3bb15b68ecd99a30eb364c4c1a393359bcad6278.