Search code examples
spring-dataspring-data-r2dbc

How to map a 1:1 relationship with Spring Data R2DBC?


I have these simplified tables

CREATE TABLE address(
    id VARCHAR(36) NOT NULL PRIMARY KEY,
    zip VARCHAR(5) NOT NULL,
    city VARCHAR(32) NOT NULL
)
CREATE TABLE customer(
    id VARCHAR(36) NOT NULL PRIMARY KEY,
    name VARCHAR(32) NOT NULL,
    address_fk VARCHAR(36) NOT NULL,
    FOREIGN KEY (address_fk) REFERENCES address(id)
)

and these simplified Kotlin classes:

data class Address(val id: String, val zip: String, val city: String)
data class Kunde(val id: String?, val name: String, val address: Address)

When I use @Column(address_fk) for the property address I get a ConverterNotFoundException that no converter from String to Address was found. Also @MappedCollection instead of @Column doesn't look appropriate. Any hint is appreciated.


Solution

  • Relations are not supported yet in R2DBC https://github.com/spring-projects/spring-data-r2dbc/issues/99