0

如何在 Spring WebFlux 中为关系数据库连接多个表?

在 Spring Boot 中,为了连接两个表,我们可以执行不同的映射(@OneToOne、@ManyToOne、@OneToMany)。下面显示了一个示例,用于医生和患者之间的映射。

医生类(实体)

@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
public class Doctor {
    @Id
    private int did;
    private String dname;
    private String specs;
}

患者类别(实体)

@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
public class Patient {
    @Id
    private int id;
    private String name;
    private int age;

    @OneToOne(targetEntity = Doctor.class,cascade = CascadeType.ALL)
    @JoinColumn(name = "Id_Fk")
    private Doctor doctor;
}

对于 Spring Webflux,我创建了如下所示的两个表(postgresSQL),它们各自的存储库、一个处理程序和一个 IntelliJ 中的路由器。如何在 Spring Webflux 中编写上述代码,因为我们不能在那里使用 @Entity 或任何映射注释?

医生桌

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Doctor {
    @Id
    private int did;
    private String dname;
    private String specs;
}

病人桌

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Patient {
    @Id
    private int pid;
    private String name;
    private int age;
}
4

0 回答 0