1
votes

I intend to implement the batch to read data from various DB tables to populate the complex domain below, then perform calculation in processor and load the data into DB via writer.

public class A{

  private String id;
  private String name;
  private ArrayList list1;
  private ArrayList list2;

  ......
}

Now, I am stuck at the design of the reader. The idea is to query DB table to get a list of id, then query the other fields including list1 and list 2 based on each id. It seems the existing reader can not fulfill this requirement, do I need to create custom reader to achieve the goal? I think I would take chunk approach, but has no clue how to implement it.

Code example is much appreciated.

1

1 Answers

0
votes

You can use the driving query pattern. The reader reads only the IDs and then the processor can query the details of each object based on the ID.

This is a common pattern and you can find more details about it in the common batch patterns section of the documentation here: https://docs.spring.io/spring-batch/4.0.x/reference/html/common-patterns.html#drivingQueryBasedItemReaders