Discriminator column displayed as a Hibernate object

In sleep mode, is it possible to have discriminator as an entity? For example, if I have a Department as a base class and AdminDepartment and ProcessingDepartment as subclasses. The DepartmentType type is a discriminator and represents an object mapped to the DEPT_TYPE table.

+3
source share
1 answer

Yes, perhaps, although this attitude will be read-only:

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

All Articles