I have a process that uses a chunk to read a file and insert the records into a table. I need to be able to insert a row into a parent table at the opening of the input file and when the file is closed I need to update that parent table row inserted at the start. Is there a listener or approach to make this happen?
The closest one is StepListener, where you can implement its beforeStep
and afterStep
method to update the parent table. You can inject StepContext
into the step listener class to access context data through step metrics or step transient data.
But beforeStep
is called before opening the input file. Not sure if this diff is significant for your case.
Otherwise, you can implement your own item reader class to achieve your requirement.