Add NamedParameterJdbcTemplate#batchUpdate
methods taking KeyHolder
and String[] keyColumnNames
as counterparts to the NamedParameterJdbcTemplate#update
methods of the same form.
This is in service of an enhancement to spring-data-jdbc
to perform batch inserts to persist collections of entities referenced by an aggregate, when adequately supported by the database. The proposed changes to spring-data-jdbc
currently include a copy of the changes being proposed here, and could be refactored to use the respective NamedParameterJdbcTemplate#batchUpdate
once accepted and merged.
Related to spring-projects/spring-framework#6530.
Comment From: trisberg
I'm getting some checkstyle violations trying to build. Could you fix them so I can try this out? Thanks.
Comment From: ctailor2
@trisberg I resolved the checkstyle violations and made some other updates.
Comment From: pworoniecki
Any update on this topic? Is it abandoned or is something still to be considered? Would be great to have this code merged (though I guess it needs some adjustment to the current state of the code).
Comment From: sabomichal
Would be nice to have this merged already.
Comment From: ePaul
I just spent some hours trying to figure out how to implement this myself (or rather, how to generalize this Stack Overflow answer into something which works for my use case).
Only then I had the idea of checking whether someone already did something here, and it looks good.
Comment From: snicoll
@ctailor2 thanks for the PR, it misses some tests for the changes in NamedParameterJdbcTemplate
though.
@schauder can you share your thoughts? I can see something in spring data jdbc was merged with a reference to a core framework class and I am a bit puzzled by that.
Comment From: schauder
@snicoll not sure what kind of thoughts you are looking for.
The changes in Spring Data JDBC are creating a copy of frameworks NamedParameterJdbcTemplate
with the changes of this PR included, because we really needed the changes. We would be glad to go back to the official NamedParameterJdbcTemplate
once this PR is merged.
Comment From: snicoll
@ctailor2 and all, thanks for your patience and please use NamedParameterJdbcTemplate
proper again.