0
votes

I have a spring batch job. Whose reader reads some records from DB by some complex sql. Now for every record i received from DB, i have to hit one more table to fetch some attributes. Note :- I can't join this table sql in reader step. So these fetched attributes along with data from existing record i need to write down to file. Can this done with Spring batch?

1

1 Answers

0
votes

Yes that's possible using an item processor that would fetch additional data for each item. This is a common pattern know as the "driving query pattern" and is described in the Common Batch Patterns section.

However, this pattern is not the best in terms of performance (for huge data sets) as you will have an additional query for each item (N+1 query issue) but it is useful and efficient for most use cases with medium/small data sets.