Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 子实体层次结构上的JPA继承注释_Java_Jpa_Orm_Jpa 2.0 - Fatal编程技术网

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

Java 子实体层次结构上的JPA继承注释,java,jpa,orm,jpa-2.0,Java,Jpa,Orm,Jpa 2.0,是否可以在不同的层次结构中使用@Inheritance注释和不同的策略 The inheritance strategy and the discriminator column are only specified in the root of an entity class hierarchy or subhierarchy . 但是允许不同的策略吗?我不这样认为,如果我错了,请纠正我。您可以将混合继承用于应用不同策略的相同层次结构。使用 @SecondaryTable( name =

是否可以在不同的层次结构中使用@Inheritance注释和不同的策略

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


但是允许不同的策略吗?

我不这样认为,如果我错了,请纠正我。您可以将
混合继承
用于应用不同策略的相同层次结构。使用

@SecondaryTable(
name = "SUBTABLE",
pkJoinColumns = @PrimaryKeyJoinColumn(name = "SUB_TABLE_ID");

在子类定义之前。使用此方法,您可以应用例如
SINGLE_TABLE
策略,并使用单独的子类表

不支持在单个实体继承层次结构中混合继承策略。JPA规范规定:

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


所以最终的结果是没有任何冲突或支持。正确的JPA并没有定义行为。实现者可以定义一个行为,但是使用该行为是不可移植的。