Hi guys, i have Record table which contain @EmbeddedId. I try to add in Record entity which already it contains, by using @JoinTable. I need add to Record two different Doctors without many-to-many relation. Functionally it will be two diffrent Doctor. Can you help me ?
Code:
@Table(name = "T_Record")
public class Record{
@EmbeddedId
private RecordPrimaryKey id;
@ManyToOne(targetEntity = Operation.class)
@JoinColumn(name = "operationID")
private Operation operation;
@ManyToOne(targetEntity = Patient.class)
@JoinColumn(name = "patientID")
private Patient patient;
@ManyToOne(targetEntity = Doctor.class)
@JoinTable(
name = "Doctor_Record",
joinColumns = { @JoinColumn(name = "RecordPrimaryKey")},
inverseJoinColumns = {@JoinColumn(name="doctorId",referencedColumnName="id")}
)
private Doctor doctor;
Code:
@Entity
@Table(name = "T_Doctor")
public class Doctor extends User {
@Column(name = "specialisation")
private String specialisation;
@Column(name = "category")
private String category;
@Column(name = "work", length = 128)
private String work;
@Column(name = "card_number", length = 16)
private Long cardNumber;
@Column(name = "bank_name")
private String bankName;
@OneToMany(targetEntity = Record.class)
private List<Record> records;