[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
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

 Description   

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.



 Comments   
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:

https://github.com/spring-projects/spring-data-mongodb/commit/d4f1ef8704ac8907dce91ad0c14d194027a3487e

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 Mon Jul 24 02:45:32 UTC 2017 using JIRA 6.4.14#64029-sha1:ae256fe0fbb912241490ff1cecfb323ea0905ca5.