Reputation: 85
I am using a int-jdbc:inbound-channel-adapter. I am facing issue with my update statement.I need pass single value ,since I have hard coded that value in RowMapper ,that's why I am receiving 5 values in place of 1.(max-rows-per-poll=5)
My Requirement :- I need to pass a system variable to the node_id column and 5 ids select from select query to in condition
<int-jdbc:inbound-channel-adapter id="itemsInboundJdbcChannelAdapter"
auto-startup="true" data-source="dataSource" channel="ItemsInboundJdbcChannel"
query="SELECT QXXXX_ID,BXXXX_ID,TXXXX_ID,RXXXX_ID,EXXXXID,NODE_ID FROM XXXX_QXXXX WHERE XXXX_STATUS = :identier ORDER BY QXXXX_ID asc FOR UPDATE SKIP LOCKED"
update="UPDATE XXXX_QXXXX SET XXXX_STATUS ='IT_PROCESSED',NODE_ID=(:NODE_ID),UPDATE_BY='BISWO',UPDATED_ON=SYSDATE WHERE QXXXX_ID IN (:QXXXX_ID)"
row-mapper="xxDataRowMapper" max-rows-per-poll="${item.transfer.jdbc.max.rows}"
select-sql-parameter-source="myItemsSelectSqlParameterSource"
update-sql-parameter-source-factory="myUpdateParameterSource">
<int:poller id="jdbcPoller" fixed-delay="${item.transfer.poller.jdbc.fixed.delay}" task-executor="notificationExecutor" error-channel="chainToFailedOut">
<int:transactional transaction-manager="transactionManager" />
</int:poller>
</int-jdbc:inbound-channel-adapter>
<int:service-activator input-channel="ItemsInboundJdbcChannel"
ref="getMyService" >
<int:poller fixed-delay="${item.transfer.poller.jdbc.fixed.delay}" />
</int:service-activator>
<bean id="myUpdateParameterSource"
class="org.springframework.integration.jdbc.ExpressionEvaluatingSqlParameterSourceFactory">
<property name="parameterExpressions">
<map>
<entry key="NODE_ID" value=" #this['nodeId']"/>
<entry key="QXXXX_ID" value="#this['qxxxxId']" />
</map>
</property>
</bean>
xxxDataRowMapper.java
@Override
public XXXDataModel mapRow(ResultSet rs, int rowNum) throws SQLException {
XXDataModel object=null;
if(rs!=null){
long queueId=rs.getLong("QXXXX_ID");
long batchId=rs.getLong("BXXXX_ID");
long tradeRunId=rs.getLong("TXXXX_ID");
long riskRunId=rs.getLong("RXXXX_RUN_ID");
long eventId=rs.getLong("EXXXXID");
object=new XXDataModel(queueId,batchId,tradeRunId,riskRunId,eventId,this.nodeId);
}
return object;
}
Upvotes: 1
Views: 519
Reputation: 121262
I think you simply can go the same properties placeholder
way and do something like this:
update="UPDATE XXXX_QXXXX SET XXXX_STATUS ='IT_PROCESSED',NODE_ID='${node_id.from-system.properties}', UPDATE_BY='BISWO',UPDATED_ON=SYSDATE WHERE QXXXX_ID IN (:QXXXX_ID)"
Spring will understand your PP pattern, resolves it against an Environment
and the final value will be present in the target SQL statement to use.
Upvotes: 1