2014-10-17 48 views
0

我想寫JdbcPagingItemReader與像一個複雜的查詢:JdbcPagingItemReader具有多個選擇查詢

從YYY選擇XXX,​​其中a = b和c =(從(F)YYY其中A = B選擇最大)

...帶參數。

這裏是我寫我的查詢:

<bean 
      class="org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean"> 
      <property name="dataSource" ref="dataSource" /> 
      <property name="selectClause" value="SELECT ohrefnum" /> 
      <property name="fromClause" value="FROM orderhdr_all" /> 
      <property name="whereClause" 
       value="WHERE customer_id =: CUSTOMER_ID AND ohentdate = (SELECT MAX (ohentdate) FROM orderhdr_all WHERE customer_id =: CUSTOMER_ID)" /> 
      <property name="sortKey" value="ohrefnum" /> 
     </bean> 

,但它引發以下錯誤:java.sql.SQLException: Missing IN or OUT parameter at index:: 2

回答

0

我發現這個問題的起源。它只是後面的空格字符 「=:」

應該

WHERE CUSTOMER_ID =:CUSTOMER_ID)

,而不是

WHERE CUSTOMER_ID =: CUSTOMER_ID)