Source:
public Object invoke(HandleDing h, Object target, Object[] args, MethodProxy mp) { boolean foundIterator = false; Handle handle = h.getHandle(); List<Iterator<?>> extras = new ArrayList<>(); for (final Object arg : args) { if (arg instanceof Iterable) { extras.add(((Iterable<?>) arg).iterator()); foundIterator = true; } else if (arg instanceof Iterator) { extras.add((Iterator<?>) arg); foundIterator = true; } else if (arg.getClass().isArray()) { extras.add(Arrays.asList((Object[])arg).iterator()); foundIterator = true; } else { extras.add(Stream.generate(() -> arg).iterator()); } } if (!foundIterator) { throw new UnableToCreateStatementException("@SqlBatch method has no Iterable or array parameters", null, null); } int processed = 0; List<int[]> rs_parts = new ArrayList<int[]>(); PreparedBatch batch = handle.prepareBatch(sql); populateSqlObjectData((ConcreteStatementContext) batch.getContext()); applyCustomizers(batch, args); Object[] _args; int chunk_size = batchChunkSize.call(args); while ((_args = next(extras)) != null) { PreparedBatchPart part = batch.add(); applyBinders(part, _args); if (++processed == chunk_size) { processed = 0; rs_parts.add(executeBatch(handle, batch)); batch = handle.prepareBatch(sql); populateSqlObjectData((ConcreteStatementContext) batch.getContext()); applyCustomizers(batch, args); } } rs_parts.add(executeBatch(handle, batch)); int end_size = 0; for (int[] rs_part : rs_parts) { end_size += rs_part.length; } int[] rs = new int[end_size]; int offset = 0; for (int[] rs_part : rs_parts) { System.arraycopy(rs_part, 0, rs, offset, rs_part.length); offset += rs_part.length; } return rs; }

Target:
public Object invoke(HandleDing h, Object target, Object[] args, MethodProxy mp) { boolean foundIterator = false; Handle handle = h.getHandle(); List<Iterator<?>> extras = new ArrayList<>(); for (final Object arg : args) { if (arg instanceof Iterable) { extras.add(((Iterable<?>) arg).iterator()); foundIterator = true; } else if (arg instanceof Iterator) { extras.add((Iterator<?>) arg); foundIterator = true; } else if (arg.getClass().isArray()) { extras.add(Arrays.asList((Object[])arg).iterator()); foundIterator = true; } else { extras.add(Stream.generate(() -> arg).iterator()); } } if (!foundIterator) { throw new UnableToCreateStatementException("@SqlBatch method has no Iterable or array parameters," + " did you mean @SqlQuery?", null, null); } int processed = 0; List<int[]> rs_parts = new ArrayList<int[]>(); PreparedBatch batch = handle.prepareBatch(sql); populateSqlObjectData((ConcreteStatementContext) batch.getContext()); applyCustomizers(batch, args); Object[] _args; int chunk_size = batchChunkSize.call(args); while ((_args = next(extras)) != null) { PreparedBatchPart part = batch.add(); applyBinders(part, _args); if (++processed == chunk_size) { processed = 0; rs_parts.add(executeBatch(handle, batch)); batch = handle.prepareBatch(sql); populateSqlObjectData((ConcreteStatementContext) batch.getContext()); applyCustomizers(batch, args); } } rs_parts.add(executeBatch(handle, batch)); int end_size = 0; for (int[] rs_part : rs_parts) { end_size += rs_part.length; } int[] rs = new int[end_size]; int offset = 0; for (int[] rs_part : rs_parts) { System.arraycopy(rs_part, 0, rs, offset, rs_part.length); offset += rs_part.length; } return rs; }