Return Generated ID in R2dbc Insert #34604
Labels
in: data
Issues in data modules (jdbc, orm, oxm, tx)
status: waiting-for-triage
An issue we've not yet triaged or decided on
When using Postgres, it is easy to add
RETURNING id
to attach the generated ID in theFetchSpec
and extract it.But when using H2 and Spring R2dbc, there is no built-in
RETURNING
support as Postgres.The Jdbc also includes
PrepareStatement.getGeneratedKeys()
to fetch the generated key values. Spring Jdbc also include simpleGeneratedKeyHolder
to fetch the generated ID in the insert clause.Spring Data R2dbc issues also mentioned it has resolved this issue, spring-projects/spring-data-r2dbc#14.
But the raw R2dbc API includes a
Statement.returnGeneratedValues
, but it is not adopted in the Spring R2dbc.I wish there is a general solution for all database. When inserting a record, no need to add database specific RETURNING clause, provide a Spring Jdbc similar
KeyHolder
to store the generated keys in the query execution, and easily extract the key from theFetchSpec
.The text was updated successfully, but these errors were encountered: