Add batch update support to JdbcClient - #36944
Conversation
|
I'm expecting more fluent batch API like: client.sql("insert into person(name, age) values (:name, :age)").batch().param("name", name1).param("age", age1).add().param("name", name2).param("age", age2).batchUpdate(); |
7f77ae2 to
a3b4a5b
Compare
|
Updated the PR. Batch support is now a single fluent |
1a8c792 to
6864976
Compare
Introduce a fluent batch() operation on JdbcClient.StatementSpec that accumulates several sets of parameters - bound as positional or named parameters in the same fashion as a single update, separated by add() - and executes them as a single JDBC batch through batchUpdate(). Batch updates previously required dropping down to JdbcTemplate or NamedParameterJdbcTemplate. Closes gh-33843 Signed-off-by: Jiří Krokviak <j.krokviak@gmail.com>
6864976 to
808aff8
Compare
|
@Empatixx I added batch update with generated keys base on your commit, see https://github.com/quaff/spring-framework/tree/jdbcclient-batch-update |
@quaff, did you intend to submit a PR for that, or did I overlook an existing one? |
See spring-projectsGH-36944 Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
This adds batch update support to
JdbcClient, as requested in gh-33843.Batch entries are accumulated in a fluent way through a new
batch()method onStatementSpec:Each entry is bound with
param(...)/params(...)/paramSource(...)exactly like a single update;add()separates entries andbatchUpdate()executes them as one JDBC batch (the last entry is completed implicitly). Both positional and named parameters are supported (mixing the two in one batch is rejected). It delegates toJdbcOperations.batchUpdate/NamedParameterJdbcOperations.batchUpdate.Reference docs and integration tests are included. The
spring-jdbcbuild, Checkstyle and tests pass.I know this is assigned to @sdeleuze — feel free to take whatever is useful here.