Spring Batch JdbcPagingItemReader似乎没有执行所有项目 [英] Spring Batch JdbcPagingItemReader seems not EXECUTING ALL THE ITEMS

查看:857
本文介绍了Spring Batch JdbcPagingItemReader似乎没有执行所有项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,该应用程序从Oracle数据库中提取记录,然后将其导出为一个列表文件.

I'm working on an app that extract records from an Oracle database and then are exported as one single tabulated file.

但是,当我尝试使用JdbcPagingItemReader从数据库中读取数据并写入文件时,我只会得到pageSize中指定的记录数.因此,如果pageSize为10,那么我得到一个包含10行的文件,其余的记录似乎被忽略了.到目前为止,我还无法找到真正发生了什么,任何帮助都将受到欢迎.

However, when I attempt to read from the DB using JdbcPagingItemReader and write to a file I only get the number of records specified in pageSize. So if the pageSize is 10, then I get a file with 10 lines and the rest of the records seem to be ignored. So far, I haven't been able to find whats is really going on and any help would be most welcome.

这是JdbcPagingItemReader配置:

Here is the JdbcPagingItemReader config:

<bean id="databaseItemReader"
class="org.springframework.batch.item.database.JdbcPagingItemReader" >
    <property name="dataSource" ref="dataSourceTest" />
<property name="queryProvider">
  <bean
    class="org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean">
    <property name="dataSource" ref="dataSourceTest" />
    <property name="selectClause" value="SELECT *" />
    <property name="fromClause" value="FROM *****" />
    <property name="whereClause" value="where snapshot_id=:name" />
    <property name="sortKey" value="snapshot_id" />
  </bean>
</property>
<property name="parameterValues">
   <map>
    <entry key="name" value="18596" />
   </map>
</property>
    <property name="pageSize" value="100000" />
<property name="rowMapper">
    <bean class="com.mkyong.ViewRowMapper" />
</property>

<bean id="itemWriter" class="org.springframework.batch.item.file.FlatFileItemWriter">
<!-- write to this csv file -->
<property name="resource" value="file:cvs/report.csv" />
<property name="shouldDeleteIfExists" value="true" />

<property name="lineAggregator">
      <bean
       class="org.springframework.batch.item.file.transform.DelimitedLineAggregator">
    <property name="delimiter" value=";" />
    <property name="fieldExtractor">
          <bean class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor">
        <property name="names" value="ID" />
       </bean>
    </property>
       </bean>  
</property>

  <job id="testJob" xmlns="http://www.springframework.org/schema/batch">
<step id="step1">
  <tasklet>
    <chunk reader="databaseItemReader" writer="itemWriter" commit-interval="1" />
  </tasklet>
</step>

谢谢

推荐答案

应该是缺少的scope ="step":

it was the scope="step" that was missing it should be:

<bean id="databaseItemReader"
    class="org.springframework.batch.item.database.JdbcPagingItemReader" scope="step">

这篇关于Spring Batch JdbcPagingItemReader似乎没有执行所有项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆