}
}
private void doDelete(Exchange exchange) throws Exception {
SqlSessionFactory client = endpoint.getSqlSessionFactory();
SqlSession session = client.openSession();
try {
Object result;
Object in = exchange.getIn().getBody();
if (in != null) {
// lets handle arrays or collections of objects
Iterator<?> iter = ObjectHelper.createIterator(in);
while (iter.hasNext()) {
Object value = iter.next();
LOG.trace("Deleting: {} using statement: {}", value, statement);
result = session.delete(statement, value);
doProcessResult(exchange, result);
}
} else {
LOG.trace("Deleting using statement: {}", statement);
result = session.delete(statement);
doProcessResult(exchange, result);
}
session.commit();
} catch (Exception e) {
session.rollback();
throw e;
} finally {
session.close();
}
}