2017-05-24 95 views
0

嘗試使用Spring Batch讀取僅在昨天創建的數據。下面是我嘗試使用的bean,使用JdbcPagingItemReader & SqlPagingQueryProviderFactoryBean。但是,查詢沒有得到執行。Spring批處理使用> =和<Where子句

感謝您的幫助!

<bean id="customersPagingItemReader" 
    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 CUST_ID, CREATED " /> 
      <property name="fromClause" value=" from CUSTOMERS" /> 
      <property name="whereClause" value=" where CREATED &gt;= trunc(SYSDATE-1) and CREATED &lt; trunc(SYSDATE)" /> 
     </bean> 
    </property> 
    <property name="pageSize" value="5" /> 
    <property name="fetchSize" value="5" /> 
    <property name="rowMapper"> 
     <bean class="com.yahoo.affiliationapi.api.CustomerRowMapper" /> 
    </property> 
</bean> 
+1

您在執行查詢時是否收到錯誤?你能發佈你看到的任何異常嗎? –

回答

1

我能弄明白這一點。當我看到作業步驟退出消息說 - '必須指定排序鍵'

我剛纔將以下屬性添加到上面的代碼&它開始工作正常。

<property name="sortKey" value="CUST_ID" />