2

我可以定义对 jdbc 入站通道适配器的动态查询吗?

<int-jdbc:inbound-channel-adapter max-rows-per-poll="1" 
    query ="#{'select * from work where status=0 and and test='' + test.testValue+ '' order by date_modified'}"     
    channel="test" data-source="testDS" update="update work set status=1 where id in (:id)"
   >       
    <int:poller fixed-rate="100">
        <int:transactional transaction-manager="testTM"/>           
    </int:poller>       
</int-jdbc:inbound-channel-adapter>

这里我定义了一个测试 bean,它有一个方法 getTestValue()。这是行不通的。有什么建议么?

4

1 回答 1

4

尝试使用 int-jdbc:inbound-channel-adapter 的 select-sql-parameter-source 属性

<int-jdbc:inbound-channel-adapter query="select * from user where lower(username)=:key"
channel="inputChannel" data-source="dataSource"
update="UPDATE DUMMY SET DUMMY_VALUE='test'" row-mapper="personResultMapper"
select-sql-parameter-source="parameterSource" />

<bean id="parameterSource" class="Class to extend AbstractSqlParameterSource" />

扩展 AbstractSqlParameterSource 的类负责为参数提供值。

更多细节可以在:https ://gist.github.com/dsyer/472357

于 2013-05-22T10:38:53.827 回答