I tried to create a user/roles relation in RDBMS and want to use R2dbc(Spring Data R2dbc) to shake hands with the backend database.
Assume there are three tables, users, roles, and user_roles.
@Table("users")
class User {
@Id
private String username;
private String password;
private String email;
@Builder.Default
private boolean active = true;
@Builder.Default
private List<String> roles = new ArrayList<>();
@Column("created_at")
private LocalDateTime createdDate;
}
Unlike JPA, R2dbc reuses the spring-data-relational-common(which is also used in Spring Data Jdbc) to annotate the tables, but there is no facility to resolve the relations, such as the roles
here.
@MappedCollection
comes withorg.springframework.boot:spring-boot-starter-data-r2dbc:2.3.1.RELEASE
. But using it in an entity with a collection variable fails. – Peabody