Discriminator列映射为实体Hibernate [英] Discriminator column mapped as entity Hibernate
本文介绍了Discriminator列映射为实体Hibernate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
是的,尽管这样的关系是只读的, ($)
$ b $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $部门{
...
@ManyToOne
@JoinColumn(name =DEPT_TYPE_ID,可插入= false,可更新= false)
私人部门类型deptType;
...
}
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;
...
}
这篇关于Discriminator列映射为实体Hibernate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文