Discriminator列映射为实体Hibernate

时间:2012-04-23 02:04:14

标签: hibernate entity discriminator

在休眠状态下,是否可以将鉴别器作为实体?例如,如果我有Department作为基类&行政部门& ProcessingDepartment作为子类。 DepartmentType是鉴别器&是映射到DEPT_TYPE表的实体。

1 个答案:

答案 0 :(得分:5)

是的,这是可能的,尽管这种关系是只读的:

@Entity @Inheritence(...)
@DiscriminatorColumn(name = "DEPT_TYPE_ID")
public class Department {
    ...
    @ManyToOne
    @JoinColumn(name = "DEPT_TYPE_ID", insertable = false, updatable = false)
    private DepartmentType deptType;
    ...
}