【发布时间】:2011-10-04 12:02:17
【问题描述】:
这是父类 Enterprise。它有雇主,其中一位是企业总裁。
@Entity
class Enterprise
{
// fields
@OneToMany
public List<Employee> getEmployers()
// implementation
@OneToOne
public Employee getPresident()
// implementation
}
这是子 Employee 类。它只有关于他工作的企业的信息。但问题是我应该使用什么关联?
@Entity
class Employee
{
// fields
// what association should I use?
public Enterprise getEnterprise()
// implementation
}
【问题讨论】:
-
@Nathan - 因为在企业中可以有很多员工,而不仅仅是一个。
标签: java hibernate hibernate-mapping