我正在建立两个实体之间的关系
@Entity
@Table(name = "DEPARTMENT")
public class Department{
@Id
private Long id;
@Column(name = "DEPT_ID")
private String deptId;
@Column(name = "DEPT_NAME")
private String deptNAme;
}
@Entity
@Table(name = "EMPLOYEE")
public class Employee{
@Id
private Long id;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name = "DeptId")
private Department dept;
@Column(name = "EMP_ID")
private String empId;
@Column(name = "EMP_NAME")
private String empName;
}
问题是表上的员工与dept的ID有关,我想将其与deptId链接起来怎么办?
答案 0 :(得分:0)
使用
@JoinColumn(name = "DeptId" , referencedColumnName = "DEPT_ID") ;