如何在 Spring WebfluxIntelliJPostgres 数据库中加入替代映射多个表?

问题描述

如何在 Spring WebFlux for Relational Database 中加入多个表?

在 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;
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)