PS:我使用Hibernate作为JPA vendor,现在报错:</p>
引起:org.hibernate.AnnotationException:com.test.Project 的 referencedColumnNames(manager_id) 引用 com.test.FullTimeEmployee 未映射到单个属性
@Entity
@Table(name = "tb_employee")
@IdClass(EmployeePK.class)
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "employee_type", discriminatorType = DiscriminatorType.STRING)
public class Employee implements Serializable {
@Id
@Column(name = "employee_id", nullable = false, length = 50)
protected String Id;
@Id
@Column(name = "employee_type", nullable = false, length = 50)
protected String type;
public static class EmployeePK implements Serializable {
private String Id;
private String type;
}
}
@Entity
@Table(name = "tb_ft_employee")
@DiscriminatorValue("fulltime")
public class FullTimeEmployee extends Employee {
// some other properties
}
@Entity
@Table(name = "tb_project")
public class Project{
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "manager_id", referencedColumnName = "employee_id", unique = false, nullable = false,
updatable = true)
private FullTimeEmployee manager;
// some other properties
}