/**
* Calls insert on the SqlMapClient.
*/
public void process(Exchange exchange) throws Exception {
SqlMapClient client = endpoint.getSqlMapClient();
Object body = exchange.getIn().getBody();
if (body == null) {
// must be a poll so lets do a query
Message msg = exchange.getOut(true);
if (LOG.isTraceEnabled()) {
LOG.trace("Querying for list: " + statement);
}
List list = client.queryForList(statement);
msg.setBody(list);
msg.setHeader(IBatisConstants.IBATIS_STATEMENT_NAME, statement);
} else {
// lets handle arrays or collections of objects
Iterator iter = ObjectHelper.createIterator(body);
while (iter.hasNext()) {
Object value = iter.next();
if (LOG.isTraceEnabled()) {
LOG.trace("Inserting: " + value + " using statement: " + statement);
}
client.insert(statement, value);
}
}
}