【发布时间】:2017-08-22 23:46:53
【问题描述】:
我正在尝试找出要使用的适当关系,以便对需要查找表(UI 上的 Comboxbox 等效项)来从中选择值的 JPA 实体字段进行建模。下面是一个例子:
@Entity
public class Employee {
@Id
private int employeeId;
private String name;
private Department department;
}
@Entity
public class Department {
@Id
private int id;
private String name;
}
Department 的实例可能如下:
Id | Name
-----------------------
100 | Human Resources
101 | Sales
102 | Finances
对于员工,部门字段应从上述之一中获取值。两个实体中对应字段的 JPA 注释应该是什么?
谢谢,
桑迪普·约瑟夫
【问题讨论】:
-
我敢肯定,如果您真的阅读过 JPA,并搜索了 OneToOne 关系,您可能会找到一些东西
标签: jpa associations entity lookup relationships