Spring Integration :How to send array as a single payload to a jdbc : outbound gateway -
how send array single payload jdbc : outbound gateway of spring integration ? constructing array of string , sending interface method . sql accepts 1 parameter ":payload" , fails uncategorizedsqlexception.
the sql query of outbound gateway below
<int-jdbc:outbound-gateway data-source="datasource" request-channel="requestchannel" query="select xmlmsg table seq_id in (:payload)" reply-channel="replychannel" > </int-jdbc:outbound-gateway> serviceinterface.findbysequenceids(sequenceidstringarray);
actually substitutenamedparameters
in
clause parameter has collection
not array
. source code of namedparameterjdbctemplate.substitutenamedparameters
:
if (value instanceof collection) { iterator<?> entryiter = ((collection<?>) value).iterator(); int k = 0; while (entryiter.hasnext()) { if (k > 0) { actualsql.append(", "); } ...... actualsql.append("?");
so, construct list
strings, not array
:
arrays.aslist("foo", "bar", "baz");
and real query be:
select xmlmsg table seq_id in (?, ?, ?)
other work jdbctemplate
you.
update
note, default <int-jdbc:outbound-gateway/>
selects 1 record. rid limit specify max-rows-per-poll="0"
.
Comments
Post a Comment