For a spring batch job, there are steps. In those steps, you typically have a read, process (optional), and write.
What I need to accomplish is in step 1 is read from a database query and print one line from the result to a csv file. This database query could have many lines of data as a result. But I just want it to print one of those lines of data and then move on to the next step.
In the second step, I want to read from a separate database, but query this database based on the ID from the previously written data. That data has an ID. Then, from the result of this new query using that ID, I want to write every line that comes from that query to the same csv file until there is no more data to write from that query. This would all be below the previously written line from step 1.
Then, I want to repeat step 1 and print the next line from that query. Then go again to step two based on this new ID. Continue this loop until step 1 no longer has any lines of data left.
It is not clear how you can do a loop like this with Spring Batch. How can you do a loop similar to this? Especially given that I want to only print one line each time step 1 is ran.
Also, how can I share the ID from step 1 to step 2, so step 2 can use that in the query?