Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support batchUpdate in JdbcClient #30949

Closed
making opened this issue Jul 26, 2023 · 5 comments
Closed

Support batchUpdate in JdbcClient #30949

making opened this issue Jul 26, 2023 · 5 comments
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) status: declined A suggestion or change that we don't feel we should currently apply

Comments

@making
Copy link
Member

making commented Jul 26, 2023

JdbcClient introduced in #30931 is missing batchUpdate method

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jul 26, 2023
@jhoeller jhoeller self-assigned this Jul 26, 2023
@jhoeller jhoeller added the in: data Issues in data modules (jdbc, orm, oxm, tx) label Jul 26, 2023
@jhoeller
Copy link
Contributor

This is intentional since batchUpdate is a rather awkward method to provide parameters for... in a JdbcClient style. From a design perspective, JdbcClient is a more convincing arrangement if it just addresses individual statement executions.

Also, we got SimpleJdbcInsert in the same package providing a sophisticated arrangement for batch inserts as well. On a related note, SimpleJdbcCall provides a similar arrangement for stored procedure calls which JdbcClient does not cover either. Alternatively, there is always JdbcTemplate itself for custom batch update needs.

In terms of broader alignment, DatabaseClient does not provide support for batch updates either. Granted, R2DBC comes with a different arrangement there but equally hard to parameterize in a fluent style, as far as I'm concerned.

@jhoeller jhoeller added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jul 26, 2023
@hantsy
Copy link
Contributor

hantsy commented Jul 27, 2023

Yesterday I was just confused why lacks batch update in JdbcClient .

So the the solution is SimpleJdbcInsert?

@making
Copy link
Member Author

making commented Jul 27, 2023

you can use JdbcTemplate for batchUpdate directly

@shirishpandharikar
Copy link

shirishpandharikar commented Mar 28, 2024

Is there a possibility to expose the underlying JdbcTemplate or NamedParameterJdbcTemplate from the JdbcClient. Instead of having both JdbcClient and JdbcTemplate or NamedParameterJdbcTemplate it would be good if both of them can be accessed and batch operation be executed.

@IgnatBeresnev
Copy link

IgnatBeresnev commented Sep 16, 2024

Definitely agree with @shirishpandharikar

  • I'm unable to use SimpleJdbcInsert since I need to add an "ON CONFLICT ..." to the batch statement
  • I don't want to rely on order, so I have to use NamedParameterJdbcTemplate
  • For my select queries I use JdbcClient

So I end up injecting both JdbcClient and JdbcTemplate, from which I additionally construct NamedParameterJdbcTemplate where needed.

I'd like to inject only JdbcClient so that my colleagues are not confused whether to use JdbcTemplate, NamedParameterJdbcTemplate or JdbcClient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

No branches or pull requests

6 participants