【发布时间】:2012-02-08 04:20:51
【问题描述】:
我有一个层次结构的 JPA 映射,它有几个类深。像这样的
@Entity
@Inheritance(strategy= InheritanceType.SINGLE_TABLE)
public abstract class BaseEntityClass implements Serializable {
// lots of stuff common to all my entities.
}
@Entity
@Inheritance(strategy= InheritanceType.TABLE_PER_CLASS)
public abstract class EntityTypeOne extends BaseEntityClass {
// stuff common to EntityTypeOne
}
@Entity
@Inheritance(strategy= InheritanceType.TABLE_PER_CLASS)
public abstract class EntityTypeTwo extends BaseEntityClass {
// stuff common to EntityTypeTwo
}
我知道您使用带有超类的@Inheritence 方法来定义映射策略。但这如何与深层层次结构一起工作?我希望将所有叶类映射到它们自己的表。我应该用 BaseEntityClass 做 SINGLE_TABLE 吗?
【问题讨论】:
标签: java jakarta-ee inheritance jpa orm