0

I am trying to read from db with records like one header and many related details, then I have to output to different file by the composite key of headers. For example, table countries(header) with columns: country_id, name, area table country_stats(detail) with columns: country_id, year, population, gdp

how to assgin every header+details to different file? Using ClassifierCompositeItemWriter with delegating to a list of FlatFileItemWriter? If it could be used, how I assign resource to every FlatFileItemWriter at runtime?

Please give me some hints.

dandelion
  • 5
  • 4
  • How many stats records are there for each country? In other words, is the relation country -> stats one-to-one or one-to-many? This is key to correctly answer your question. – Mahmoud Ben Hassine Mar 06 '23 at 17:18
  • the number of detail records for each header data is not fixed. It is one-to-many relationship. MultiResourceItemWriter might not fit this scenario. – dandelion Mar 07 '23 at 01:05
  • You can find an example here: https://stackoverflow.com/questions/67604628/spring-batch-classifiercompositeitemwriter-footer-not-getting-called/67635289#67635289 – Mahmoud Ben Hassine Mar 14 '23 at 20:30

0 Answers0