public BatchDeleteOptimized(String tableName, List<String> whereColumns, Iterable<A> xs,
Try3<Integer, PreparedStatement, A, Integer, SQLException> binder, int batchSize)
{
int whereColumnsLength = whereColumns.size();
op = DbOps.toChunks(xs, ys -> {
String colsSegment = "(" + StringUtil.join(whereColumns, ", ") + ")";
String sql = MessageFormat.format(SQL_TEMPLATE, tableName, colsSegment,
SqlStringUtils.placeholderRows(Collections.size(xs), whereColumnsLength));
TryEffect1<PreparedStatement, SQLException> populatedBinder = iterableBinder(binder, xs);
return new DB<Integer>()
{
@Override
public Integer run(Connection c) throws SQLException
{
try (PreparedStatement ps = c.prepareStatement(sql))
{
populatedBinder.f(ps);
return ps.executeUpdate();
}
}
};
}, batchSize);
}