In hibernate, is it possible to have discriminator as an entity? For example, if I have Department as the base class & AdminDepartment & ProcessingDepartment as subclasses. DepartmentType is the discriminator & is an entity mapped to DEPT_TYPE table.
Yes, it's possible, though such a relationship 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;
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With