1

I am using the R2DBC repository for Reactive operations. I am trying to insert a record that has aggregated java object in it. e.g. Person is an entity inside that I have Address is a different embedded class reference. Now, I want to insert the Person object data into the database.

My class and database structure looks like below:

@Data
@NoArgsConstructor 
public class Person {
  @Id
  private Long id;
  
  private String name;
  private Address address;
}

@NoArgsConstructor
@Data
public class Address {

  private String city;
  private String state;
}

PostgreSQL Person table structure:

CREATE TABLE Person(
   ID INT PRIMARY KEY     NOT NULL,
   NAME           TEXT    NOT NULL,
   CITY           TEXT    NOT NULL,
   STATE          TEXT    NOT NULL,
);

NOTE: I know how to achieve this using the JPA repository. i.e. by using @Embedded and @Embeddable annotation. But I am finding a way to do the same using the R2DBC repository.

Also wants to confirm, I have read somewhere in the blog that R2DBC does not support such embedded-like structure as used for entity classes. Also, it does not support associations like OneToOne, OneToMany, ManyToOne, and ManyToMany.

  • You heard that right as of now it does not support any of that but adding that feature is not so hard in my opinion. – nicholasnet Nov 24 '21 at 23:52

0 Answers0