子实体层次结构上的JPA继承注释

时间:2014-02-18 12:33:27

标签: java jpa orm jpa-2.0

是否可以在不同的层次结构中使用@Inheritence Annotation和不同的策略?

Inheritence strategy hierarchy

The inheritance strategy and the discriminator column are only specified in the root of an entity class
hierarchy or subhierarchy .

但允许不同的策略?

2 个答案:

答案 0 :(得分:0)

我不这么认为,如果我错了,请纠正我。您可以使用具有相同层次结构的mixed-inheritance应用不同的策略。使用

@SecondaryTable(
name = "SUBTABLE",
pkJoinColumns = @PrimaryKeyJoinColumn(name = "SUB_TABLE_ID");
在您的子类定义之前

。使用此方法,您可以应用示例SINGLE_TABLE策略并分隔子类表。

答案 1 :(得分:0)

在单个实体继承层次结构中混合继承策略不是受支持的JPA配置。 JPA规范声明:

  

此规范未定义单个实体继承层次结构中的继承策略组合。