Results 1 to 5 of 5

Thread: Driving Query pattern and composites

  1. #1
    Join Date
    Jun 2011
    Posts
    19

    Default 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 at 08:12 PM.

  2. #2
    Join Date
    Dec 2005
    Location
    Lyon, France
    Posts
    311

    Default

    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. #3
    Join Date
    Jun 2011
    Posts
    19

    Default

    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. #4
    Join Date
    Jun 2011
    Posts
    19

    Default

    Arno

    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. #5
    Join Date
    Dec 2005
    Location
    Lyon, France
    Posts
    311

    Default

    Quote 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •