0

I am writing a java application to read data from one table and writing it in some file. Our table have million of records, which we need to read daily and write in file. So, I am using Spring batch with reader as JdbcPagingItemReader, as I want to read records in pages. Below is my bean defination :-

<bean id="pagingItemReader" class="org.springframework.batch.item.database.JdbcPagingItemReader"
      scope="step">
    <property name="dataSource" ref="dataSource" />
    <property name="queryProvider">
      <bean
        class="org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="selectClause" value="select user_id, user_name , address" />
        <property name="fromClause" value="from mySchema.test" />
        <property name="whereClause" value="where address <> ''" />
        <property name="sortKey" value="user_id" />
      </bean>
    </property>
    <property name="pageSize" value="1000" />
    <property name="rowMapper">
        <bean class="com.myCompany.myClient.batch.reader.userVO" />
    </property>
</bean>

Spring generates the query internally like this :-

SELECT user_id, user_name , address  FROM mySchema.test ORDER BY user_id ASC FETCH FIRST 1000 ROWS ONLY

However, I am using DB2 database ,with global setting to take lock during the read. So avoid this, we use "with ur" in every query,we write. So I want my query to be generated as :-

   SELECT user_id, user_name , address  FROM mySchema.test ORDER BY user_id ASC FETCH FIRST 1000 ROWS ONLY with ur

I am not able to find anyway to do same. Kindly let me know how to append some extra part in query while using JdbcPagingItemReader.

Panther
  • 3,312
  • 9
  • 27
  • 50

1 Answers1

3

JdbcPagingItemReader allow you to set a PagingQueryProvider; maybe using a custom one - instead of using the one generated by SqlPagingQueryProviderFactoryBean - can solve your problem

Luca Basso Ricci
  • 17,829
  • 2
  • 47
  • 69