我有3张桌子顾问,患者和诊断。 诊断具有作为外键的顾问和患者属性。 我想知道如何在春季展示这个。 到目前为止,我是Consultant.java

   private String name;    private String pos;     @OneToMany(fetch = FetchType.LAZY, mappedBy = "consultant")     private List<Diagnosis> diagnosis; 

Diagnosis.java

public class Request {     private String token;     private String comment;     private boolean status;      @ManyToOne(fetch = FetchType.LAZY)     @JoinColumn(name = "Patient_id") @JoinColumn(name = "Consultant_id") //not sure about this syntax     private Consultant consultant;     private Patient patient; 

Patient.java

 private String name;    private int pid;     @OneToMany(fetch = FetchType.LAZY, mappedBy = "patient")     private List<Diagnosis> diagnosis; 

请这是怎么回事? 我也使用postgresql。

PS我是Spring框架的新手

===============>>#1 票数:1

如果您有2个实体,为什么要注释一个字段? 每个关系都应正确标注:

@ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "Patient_id") private Patient patient;  @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "Consultant_id") private Consultant consultant; 

  ask by B.obed translate from so

本文未有回复,本站智能推荐: