I am trying to replicate some functionality that I was using in Spring Data JPA in the new reactive Data r2dbc. I am aware that r2dbc is not a full-fledged ORM but wanted to understand as what could be the best way to replicate the below scenario in r2dbc:
public class Doctor extends BaseModel {
//other fields and id
@NotNull
@Enumerated(EnumType.STRING)
@ElementCollection(fetch = FetchType.LAZY, targetClass = Language.class)
@CollectionTable(name = "doctor_language",
joinColumns = @JoinColumn(name = "doctor_id"))
@Column(name = "language")
private List<Language> languages = new ArrayList<>();
@OneToMany(fetch = FetchType.LAZY, targetEntity = DoctorHealthProvider.class, mappedBy =
"doctor")
private List<DoctorHealthProvider> providers = new ArrayList<>();
// other fields
}
A simple findById call on DoctorRepository (which extends JpaRepository) will give me doctor
object with list of languages from doctor_language
table and list of health providers from health_provider
table if I use Spring Data JPA
I was reading about projections but couldn't seem to figure out the best way to implement the above in Reactive Spring. Any help/guidelines/direction is appreciated.
Thanks