how to insert data into multiple tables through ItemWriter

百般思念 提交于 2019-12-10 21:24:02

问题


how to insert data into multiple tables through ItemWriter. ItemWriter Gets input through ItemReader which selects the data from multiple tables.it should accomplish this in single step. can somebody help?


回答1:


You can use CompositeWriter of Spring Batch

<chunk reader="myReader" writer="compositeWriter" />

Composite writer, seen by your step is no different by other writers, you may look at the chunk definition above.

<bean id="compositeWriter" class="org.springframework.batch.item.support.CompositeItemWriter">
    <property name="delegates">
    <list>
        <ref bean="table1Writer" />
        <ref bean="table2Writer" />
    </list>
    </property>
</bean>

The main speciality of the CompositeWriter is that it gets a list of "delegates" which are usual Spring Batch Writers.

In this case table1Writer and table2Writer will be your implementations of jdbc writers.



来源:https://stackoverflow.com/questions/15805868/how-to-insert-data-into-multiple-tables-through-itemwriter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!