spring-projects/spring-data-r2dbc

R2DBC ORM Relationships Support

Kotlin-GDE opened this issue ยท 10 comments

hi

there any support for orm relationships in r2dbc ??

There is no relationship support so far. We might want to consider a certain degree of relationships (e.g. aggregate-scoped relations that are fetchable with a single query).

thanks

Hi,

Can I ask for an update on this please? Thanks!

Hello,

I completely know all the R2DBC suite libraries requires a lot of new functionality, but IMHO, this issue is the only one left for many projects in order to be production-ready with an stable full reactive flow. Has this development been considered?

Thanks a lot.

Likely the definition of being production-ready varies.

Right now we're blocked by relation fetching. When constructing an entity using its constructor, we require the reference to be materialized beforehand. Since constructing entities and reading those is an imperative bit, we cannot reach out to the database otherwise we would introduce blocking behavior. Another aspect is that while consuming the result stream of data, we cannot issue queries until the entire result is fully consumed, otherwise we would wait for queries that never complete. To fix the issue, we need to collect all entities into a List and post-process these later on. This arrangement clearly removes the streaming functionality which is a strong value proposition of a reactive data access layer.

Until we (or someone else) can solve both issues, we cannot provide read-relation mapping.

I have encountered the same problem when I was using Spring Data R2dbc, I hope to provide a solution like what is done in Spring Data Jdbc, https://spring.io/blog/2018/09/24/spring-data-jdbc-references-and-aggregates.

This issue should not be closed when it is not resolved.

Up!
Relational mapping would be really nice to have.

For people who are here for a workaround: DZone has a tutorial on mapping using a functional interface

Not sure why this task is closed.

dJani97, thanks but the provided workaround only works in a X-ToOne relation.

I miss a way to manage X-ToMany ones. With Jdbc you can use ResultSetExtractor to deal with all information returned by the query, is there a way to do the same with R2dbc? As far as I know, Mappers or Converters can only be used to work with one row every time.

For me yet have a problem with this. Don't have a mapper in entity class turn the code very confuses.
image
I would like have something similar below.

more informaton in #356