Hi There,
I think it is a bug.
in org.apache.camel.component.sql.SqlProducer class code highlighted in
red(line no 120) could be shifted to line no 92(highlighted in green).
else {
boolean isResultSet = ps.execute();
if (isResultSet) {
* // preserve headers*
*
exchange.getOut().getHeaders().putAll(exchange.getIn().getHeaders());*
ResultSet rs = ps.getResultSet();
SqlOutputType outputType =
getEndpoint().getOutputType();
log.trace("Got result list from query: {},
outputType={}", rs, outputType);
if (outputType == SqlOutputType.SelectList) {
List<Map<String, Object>> data =
getEndpoint().queryForList(ps.getResultSet());
// for noop=true we still want to enrich with
the row count header
if (getEndpoint().isNoop()) {
exchange.getOut().setBody(exchange.getIn().getBody());
} else {
exchange.getOut().setBody(data);
}
exchange.getOut().setHeader(SqlConstants.SQL_ROW_COUNT, data.size());
} else if (outputType == SqlOutputType.SelectOne) {
Object data =
getEndpoint().queryForObject(ps.getResultSet());
if (data != null) {
// for noop=true we still want to enrich
with the row count header
if (getEndpoint().isNoop()) {
exchange.getOut().setBody(exchange.getIn().getBody());
} else {
exchange.getOut().setBody(data);
}
exchange.getOut().setHeader(SqlConstants.SQL_ROW_COUNT, 1);
}
} else {
throw new IllegalArgumentException("Invalid
outputType=" + outputType);
}
* // preserve headers*
*
exchange.getOut().getHeaders().putAll(exchange.getIn().getHeaders());*
} else {
exchange.getIn().setHeader(SqlConstants.SQL_UPDATE_COUNT,
ps.getUpdateCount());
}
}
On Thu, Dec 5, 2013 at 2:10 PM, kuro <[email protected]> wrote:
> Hi
>
> If SQL_ROW_COUNT header is already set,
> SQL Component cannot change SQL_ROW_COUNT header value.
>
> from("direct:test")
> .setHeader(SqlConstants.SQL_ROW_COUNT).constant(100000)
> .to("sql:SELECT * FROM user WHERE FALSE")
> .filter(header(SqlConstants.SQL_ROW_COUNT).isEqualTo(100000))
> .to("log:NG");
>
>
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/bug-sql-SQL-Component-cannot-change-SQL-ROW-COUNT-header-value-tp5744350.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>