Uploaded image for project: 'Spring Data MongoDB'
  1. Spring Data MongoDB
  2. DATAMONGO-203

Add MongoOperations method that returns an Iterable<T> of converted domain objects as a result from a query

    Details

    • Type: New Feature
    • Status: Resolved
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 1.0 M3
    • Fix Version/s: None
    • Component/s: Mapping
    • Labels:
      None

      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.

        Activity

        Hide
        avalynchel Nicolas Ivering added a comment -

        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?

        Show
        avalynchel Nicolas Ivering added a comment - 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?
        Hide
        walery Walery Strauch added a comment -

        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.

        Show
        walery Walery Strauch added a comment - 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.
        Hide
        mp911de Mark Paluch added a comment -

        That's fixed with DATAMONGO-1165.

        Show
        mp911de Mark Paluch added a comment - That's fixed with DATAMONGO-1165 .

          People

          • Assignee:
            mp911de Mark Paluch
            Reporter:
            mark.pollack Mark Pollack
            Last updater:
            Mark Paluch
          • Votes:
            6 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: