我可以为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()。 这不起作用。 有什么建议吗?
答案 0 :(得分:4)
尝试使用int-jdbc的select-sql-parameter-source属性:inbound-channel-adapter
<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