我有一个与 PatientVisitObject.java 一对一映射的 PatientVisit.java:
@Entity
@Table(name = "P_Visit")
public class PatientVisit extends Bean {
@Id
@Column(name = "PATIENT_VISIT_SEQ")
private Long patientVisitSeq;
@Column(name = "PATIENT_FIRST_NM")
private String firstName;
@Column(name = "PATIENT_LAST_NM")
private String lastName;
@Column(name = "PATIENT_MIDDLE_NM")
private String middleName;
@OneToOne
private PatientVisitObject pvo;
}
PatientVisitObject.java 有一个复合键。我需要将 key.patientVisitSeq 映射到 PatientVisit.java 中的 patientVisitSeq。
@Entity
@Table(name = "Patient_V_O")
public class PatientVisitObject extends Bean {
@Id
private PatientVisitObjectKey key;
@Column(name = "FIELD")
private String field;
}
这是关键:
@Embeddable
public class PatientVisitObjectKey implements Serializable {
@Column(name = "PATIENT_VISIT_SEQ")
private Long patientVisitSeq;
@Column(name = "PATIENT_VISIT_OBJECT_SEQ")
private Long patientVisitObjectSeq;
}
我尝试使用 @JoinTable 注释,但无法正确使用。有人可以给我一些指导。谢谢。