Writing in multiple related tables in spring batch

15 views Asked by At

I need to write three tables with a steplet: A, B and C. B references A with a foreing key, C references B with a foreing key

In both cases, the foreign key is the primary key of the parent table, which is auto generated by a sequence.

I tried using a composite writer (writes A, then B and then C), but I cannot retrieve the generated id to use it in the next statement.

I know I could programmatically set the ids by querying the sequence and then increment it by the size of the data, but I don't like this option much.

Is there a more straightforward way to achieve this behaviour? Should I write different steplets, each of which reads the table updated by the previous one, sets the ids and then writes the other table?

0

There are 0 answers