Skip to content

Add batch update support to JdbcClient#36944

Open
Empatixx wants to merge 1 commit into
spring-projects:mainfrom
Empatixx:feature/jdbcclient-batch-update
Open

Add batch update support to JdbcClient#36944
Empatixx wants to merge 1 commit into
spring-projects:mainfrom
Empatixx:feature/jdbcclient-batch-update

Conversation

@Empatixx

Copy link
Copy Markdown

This adds batch update support to JdbcClient, requested in #33843.

It adds two terminal methods to JdbcClient.StatementSpec:

  • int[] batchUpdate(List<Object[]> batchArgs) — positional ? parameters
  • int[] batchUpdate(SqlParameterSource... batchArgs) — named :x parameters

They simply delegate to JdbcOperations.batchUpdate and NamedParameterJdbcOperations.batchUpdate, so batch updates no longer need to drop down to JdbcTemplate or NamedParameterJdbcTemplate.

Also adds integration tests (indexed + named) and updates the reference docs.

This issue is assigned to @sdeleuze — happy to adjust the API shape if you prefer a different design.

Introduce batchUpdate(List<Object[]>) and
batchUpdate(SqlParameterSource...) terminal operations on
JdbcClient.StatementSpec, delegating to JdbcOperations and
NamedParameterJdbcOperations respectively. Batch updates previously
required dropping down to JdbcTemplate or NamedParameterJdbcTemplate.

Closes spring-projectsgh-33843

Signed-off-by: Jiří Krokviak <j.krokviak@gmail.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 17, 2026
@quaff

quaff commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

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).end().update();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants