Multiple batch updates in NamedParameterJdbcOperations #34354
+130
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Feature request: Support for multiple batch updates in
NamedParameterJdbcOperations
, similar to the existing support inJdbcOperations
.Motivation: In my work,
NamedParameterJdbcOperations
is often used because of readability. I've come across cases where there is a big collection that needs to be executed in multiple batches. For that I see people doing one of the following:JdbcOperations.batchUpdate(String sql, Collection<T> batchArgs, int batchSize, ParameterizedPreparedStatementSetter<T> pss)
. It works great, but for many parameters, it can get complex from readability point of view due to many?
.NamedParameterJdbcOperations.batchUpdate(String sql, SqlParameterSource[] batchArgs)
is used. The splitting of the collection can be error prone, and is always done in different ways, for loops, streams. The operation gets cluttered with if / else and loops for the sake of parameter names in the query.It would be nice to have a multiple batch support in NamedParameterJdbcOperations. So we can replace (example):
With: