Announcement Announcement Module
No announcement yet.
Driving Query pattern and composites Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Driving Query pattern and composites

    Actually it is not a composite, it is a wrapper object, an account with orders.

    I am a bit blank on how I would implement the driving query pattern for my case:

    - I retrieve a set of domain objects with a reader (jdbc).
    - Each object is passed to a processor which uses a key of the previously retrieved domain object and retrieves a set of other objects.
    - I have a composite composed of the first retrieved object and the set of objects retrieved in the previous step.
    - I want to write the first object and one item of the set in a file.
    - Next line repeats the first object and the second item of the set.
    - Continues writing the first item with the next item in the set until the set is processed.

    I looked at the aggregators and thougt of overriding write in the FlatFileItemReader but since getOutputState is not accessible I did not look any further on overriding.
    Extractor would not work because I am only able to pass back one line.

    So the general question I think is how can I control writing of a composite?

    Any ideas greatly appreciated.
    Last edited by TarikS; Jun 15th, 2011, 08:12 PM.

  • #2
    you can try to return a list for each item in the processor and use a item writer that will receive a List<List<YourClass>>, iterate other each item and delegate to an out-of-the-box writer?


    • #3
      Thank you Arno for your reply!

      I found another way which looks like this:

      - I have a reader that reads the account details (number, account holder name, etc.) from a db.
      - The processor is CompositeItemProcessor:
      - The first processor (aggregator) retrieves the orders of the account and stores it in holder which contains the account and the list of orders.
      - The second processor (splitter) decomposes the holder and creates a lineitem object (another holder) that contains the account and one of the orders, creating a list of line items and returning the list of lineitem's.
      - The writer (FlatFileItemWriter) uses a RecursiveCollectionLineAggregator which delegates to a DelimitedLineAggregator.
      - The Extractor just creates the object array.

      Nice framework, everything there


      • #4

        That was what I was not sure of actually, how to implement an itemwriter without missing the functionality of the underlying database job handling ... if you'd have a pseudo example I'd be very interested.


        • #5
          Originally posted by TarikS View Post
          how to implement an itemwriter without missing the functionality of the underlying database job handling
          I'm afraid I don't see what you mean.