【发布时间】:2014-02-18 12:33:26
【问题描述】:
是否可以在不同的层次使用@Inheritence Annotation 和不同的策略?
The inheritance strategy and the discriminator column are only specified in the root of an entity class
hierarchy or subhierarchy .
但允许不同的策略?
【问题讨论】:
是否可以在不同的层次使用@Inheritence Annotation 和不同的策略?
The inheritance strategy and the discriminator column are only specified in the root of an entity class
hierarchy or subhierarchy .
但允许不同的策略?
【问题讨论】:
在单个实体继承层次结构中混合继承策略不是受支持的 JPA 配置。 JPA 规范指出:
本规范未定义单个实体继承层次结构中的继承策略组合。
【讨论】:
我不这么认为,如果我错了,请纠正我。您可以使用具有相同层次结构的mixed-inheritance 应用不同的策略。使用
@SecondaryTable(
name = "SUBTABLE",
pkJoinColumns = @PrimaryKeyJoinColumn(name = "SUB_TABLE_ID");
在您的子类定义之前。使用它,您可以应用例如SINGLE_TABLE 策略并分离子类表。
【讨论】: