I am using Spring data r2dbc and it doesn't support many to many mapping.
Tables :-
user
user_role
user_role_mapping
As usual, one user can have multiple mapping.
Sql query,
select * from user u, user_role_mapping urm, user_role ur where u.user_id = :userId and u.org_id = :orgId and u.user_id = urm.user_id and ur.role_id = urm.role_id
Here, I have a model object with all the properties from all 3 classes. Here, since user has multiple roles, I am getting multiple records and then constructing single record with user details and List of roles.
Model calss,
class User {
private long userId;
private String userName;
private List<String> roles;
}
Is there any out of the box support from Spring r2dbc which returns one user object with user details and List<String>
roles.