JdbcClient introduced in https://github.com/spring-projects/spring-framework/issues/30931 is missing batchUpdate method
Comment From: jhoeller
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.
Comment From: hantsy
Yesterday I was just confused why lacks batch update in JdbcClient .
So the the solution is SimpleJdbcInsert?
Comment From: making
you can use JdbcTemplate for batchUpdate directly
Comment From: shirishpandharikar
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.
Comment From: IgnatBeresnev
Definitely agree with @shirishpandharikar
- I'm unable to use
SimpleJdbcInsertsince 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.