-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Add support for Class-based mapping in DatabaseClient #26021
Comments
I've added this to our backlog for the time being but I'd be happy to bring it into a 5.3.x release soon. To get started, ideally we'd have at least a sketch of what such a method's implementation should look like. Are we trying to make this fully pluggable or are we rather just baking in some common cases out of the box, leaving the rest up to custom mapping functions? |
Generally speaking, it would be convenient to use Spring Data (or any other mapping framework) if it is on the classpath when mapping query results, regardless of the SQL connector technology (JDBC or R2DBC). A pluggable variant could provide streamlined instantiation strategies (for example reflection-less) or apply column-name mappings but it comes with increased complexity and the need for an SPI. A non-pluggable arrangement could serve for the most common use-cases. Such an API needs to differentiate whether the target type is expected to map onto a single column ( Since R2DBC driver primitives vary across drivers, it doesn't make sense to update our framework code for each new driver that we discover. I wonder whether it would make sense to provide an API on R2DBC level that allows consumers to identify R2DBC and driver primitives (r2dbc/r2dbc-spi#192). |
Could we port |
Any updates on that ?! |
It seems |
How to handle custom converters in this case? I have some JSONB field, which requires custom converter, and when I'm trying to call
|
Not sure whether this is the right issue to report this, but the documentation still says 'as' is supported. Is the documentation wrong or has this issue been resolved ? See here: https://spring.io/projects/spring-data-r2dbc which has this example code in it:
|
No thats not available anymore and is deprecated. |
Following up on @schauder suggestion to port |
There seems to be a bit more depth to this issue, but I'm in the process of porting the |
Note that something similar is available through Unfortunately, this is not totally straightforward to provide with the R2DBC |
I'm introducing a In contrast to Note that plain field holders are not supported since this does not seem idiomatic with R2DBC. Record classes or custom classes with constructors and/or bean-style accessors can be very concise and are actually better suited for inline use in a reactive pipeline, this is showing particularly well for parameter objects (#27282) which we also support now. |
Spring Data R2DBC's
DatabaseClient
provided a rich fluent API including functionality that allowed a convenient mapping of results into a particular type throughas(Class)
. During the migration ofDatabaseClient
we decided to drop that functionality to provide functionality that we knew how to provide from a Spring Framework perspective. Target object mapping in Spring Data used core Spring Data functionality that isn't available on the Spring Framework level.We see a lot of demand for a method that is convenient to use from the caller side and that applies convention-based mapping of primitives (Java primitives and R2DBC primitives) and data classes.
Right now, mapping requires a mapping function to be used through
map(BiFunction<Row, RowMetadata, T>)
.The text was updated successfully, but these errors were encountered: