简体   繁体   中英

How to implement multiple Reader using db in Spring Batch

This code is a version of Spring Batch version 1. I have problem migrating this code to version 4 since the org.springframework.batch.item.database.IbatisDrivingQueryItemReader class is no longer available in current version.

The process of the code below is, the withdrawalIbatisKeyGenerator bean should execute first and from the output of that bean, it will use in ibatisWithdrawalReader bean.

My question is, how to implement this reader to current version, since the two bean have dependency with each other.

<bean id="ibatisWithdrawalReader"
        class="org.springframework.batch.item.database.IbatisDrivingQueryItemReader">
        <property name="detailsQueryId"
            value="withdrawalTransactionDao.getWithdrawalTransaction" />
        <property name="sqlMapClient" ref="sqlMap" />
        <property name="keyCollector"
            ref="withdrawalIbatisKeyGenerator" />
    </bean>



<bean id="withdrawalIbatisKeyGenerator"
        class="ph.pnblife.julia.batch.BatchKeyCollector">
        <property name="drivingQuery"
            value="withdrawalTransactionDao.getWithdrawalTransactionKey" />
        <property name="restartQueryId"
            value="withdrawalTransactionDao.restartWithdrawalTransaction" />
        <property name="sqlMapClient" ref="sqlMap" />
        <property name="parameters">
            <list>
                <value>%%pricing_date_ibatis:date:pricing_date</value>
                <value>%%policy_number:string:pol_no</value>
                <value>%%version_no:string:version_no</value>
                <value>%%start_date:date:start_dt</value>
                <value>%%endt_type:string:endt_code</value>
            </list>
        </property>
        <property name="isKeyAMap">
            <value type="java.lang.Boolean">true</value>
        </property>
    </bean>

The withdrawalIbatisKeyGenerator bean could registered as a StepExecutionListener where the data required by the reader is generated in the StepExecutionListener#beforeStep method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM