java—在同一sprin批处理步骤中链接jdbccursoritemreader和storedprocedureitemreader

2q5ifsrm  于 2021-07-13  发布在  Java
关注(0)|答案(0)|浏览(185)

我想链接两个阅读器:jdbccursoritemreader和storedprocedureitemreader。第一个读取器的结果将作为参数传递给存储过程,然后此存储过程的结果将传递给某个编写器。我的两个读者会是这样的:

<bean id="centralItemReader"
        class="org.springframework.batch.item.database.JdbcCursorItemReader"
        scope="step">
        <property name="dataSource" ref="DS" />
        <property name="sql">
            <value>
                <![CDATA[
                    select num1, num2
                    from table1
                ]]>
            </value>
        </property>
        <property name="rowMapper">
            <bean class="batch.model.PubRowMapper" />
        </property>
    </bean>

    <bean id="publishProcedureReader"
        class="org.springframework.batch.item.database.StoredProcedureItemReader"
        scope="step">
        <property name="dataSource" ref="DS" />
        <property name="procedureName" value="PUBLISH"/>
        <property name="parameters">
        <list>
            <bean class="org.springframework.jdbc.core.SqlParameter">
                <!-- first parameter from the previous reader result -->
                <constructor-arg index="0" value="value_here"/>
                <constructor-arg index="1">
                    <util:constant static-field="java.sql.Types.INTEGER"/>
                </constructor-arg>
            </bean>
            <bean class="org.springframework.jdbc.core.SqlParameter">
           <!-- Second parameter from the previous reader result -->
                <constructor-arg index="0" value="value_here"/>
                <constructor-arg index="1">
                    <util:constant static-field="java.sql.Types.INTEGER"/>
                </constructor-arg>
            </bean>
        </list>
    </property>
        <property name="rowMapper">
            <bean class="batch.model.ProcedureRowMapper" />
        </property>
    </bean>

如何将结果从第一个读取器传递到第二个读取器?
在我的理解中,spring批处理步骤只包含一个reader、一个processor和一个writer
是否有某种方法可以将这两个阅读器链接为同一步中的复合阅读器?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题