Announcement Announcement Module
Collapse
No announcement yet.
Aggregating data from multiple rows into one object in ItemReader Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Aggregating data from multiple rows into one object in ItemReader

    Hi,

    I'm reading data that needs to be grouped into objects by ID (multiple rows of data into one object). I'm not able to process an object until all rows with its ID are read. How would you recommend implementing this with Spring batch? Do I need to do it in 2 steps or can I do this kind of aggregation in ItemReader?

    I have this type of data:

    ID ParameterType ParameterValue
    1 Name John
    1 Age 22
    2 Name Mike
    3 Name Pete
    And my processor should receive objects like these:

    ID Name Age
    1 John 22
    2 Mike null
    3 Pete null

  • #2
    I think I found a solution: I can use SingleItemPeekableItemReader and its peek method to find out if the next item has the same ID than the current one.

    I found an example here: http://stackoverflow.com/questions/8...r-writer-issue

    Here's the documentation of SingleItemPeekableItemReader: http://static.springsource.org/sprin...temReader.html

    Comment

    Working...
    X