如何在spring批处理中使用db实现多读取器

llycmphe  于 2021-07-24  发布在  Java
关注(0)|答案(1)|浏览(337)

此代码是SpringBatch版本1的一个版本。将此代码迁移到版本4时遇到问题,因为org.springframework.batch.item.database.ibatisdrivingqueryitemreader类在当前版本中不再可用。
下面代码的处理过程是,应该首先执行decurvatiskeygenerator bean,然后从该bean的输出中,它将在ibatisdcurvatalreader bean中使用。
我的问题是,如何将这个读取器实现到当前版本,因为这两个bean相互依赖。

<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>
vsaztqbk

vsaztqbk1#

这个 withdrawalIbatisKeyGenerator bean可以注册为 StepExecutionListener 其中读取器所需的数据是在 StepExecutionListener#beforeStep 方法。

相关问题