Details
Description
It seems there is an issue when using simple language to lookup parameters on producer endpoint in batch mode, like the following:
to("sql:insert into Table1 ( col1) values ( :#${myBean.field1})?batch=true")
DefaultSqlPrepareStatementStrategy and particular method lookupParameter(…) in class PopulateIterator tries to evaluate the specified simple expression on a body of the exchange. However when body is iterator that contains the parameter iterators for batch mode (as told in the doc: https://camel.apache.org/components/4.4.x/sql-component.html#_treatment_of_the_message_body) then simple language expression written for an object to be returned by the parameter iterator makes no sense and will always fail.
It seems when batch mode is enabled than DefaultSqlPrepareStatementStrategy.PopulateIterator needs to create a kind of fake Exchange from an object to be returned by the parameter iterator and pass to the simple language engine.
Suggested code change:
org.apache.camel.component.sql.DefaultSqlPrepareStatementStrategy.PopulateIterato r import org.apache.camel.builder.ExchangeBuilder protected static Object lookupParameter(String nextParam, Exchange exchange, Object body) { … Exchange fakeExchange = ExchangeBuilder.anExchange(camelContext).withBody(body).build(); answer = exchange.getContext().resolveLanguage("simple").createExpression(nextParam).evaluate(fakeExchange, …
Attachments
Issue Links
- links to