When we insert multiple records in one batch, very often we have a collection of records. As SimpleJdbcInsertOperations
interface has executeBatch(Map<String, ?>... batch)
only, we have to transform the collection to an array.
As the implementation in AbstractJdbcInsert::executeBatchInternal
converts the array (vararg) into a List anyway, adding a new method which accepts a Collection of Maps (executeBatch(Collection<Map<String, ?>> batch)
) seems to be straightforward and would help avoiding an additional conversion in many cases.
Comment From: foldvari
I am happy to contribute with implementing the change I am proposing supposing that there is no strong argument against the proposed change.
Comment From: snicoll
Thanks for the suggestion but we already have two excuteBatch
with a vararg so it would be more consistent to offer a variant of both, which would be impossible given that the generic type of the collection would not be taken into account.
In general, we try to avoid duplicating methods in such interface too much as it can lead to a denser API that's harder to use.