Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/326.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_Jakarta Ee_Inheritance_Jpa_Orm - Fatal编程技术网

Java JPA深度继承注释属性

Java JPA深度继承注释属性,java,jakarta-ee,inheritance,jpa,orm,Java,Jakarta Ee,Inheritance,Jpa,Orm,我有一个层次化的JPA映射,它有几个类的深度。像这样的 @Entity @Inheritance(strategy= InheritanceType.SINGLE_TABLE) public abstract class BaseEntityClass implements Serializable { // lots of stuff common to all my entities. } @Entity @Inheritance(strategy= InheritanceT

我有一个层次化的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
}

我知道您使用@Inheritance方法和超类来定义映射策略。但这在深层层次结构中是如何工作的呢?我希望所有叶类都映射到它们自己的表。我应该用BaseEntityClass做单表吗

您的基类应按类标记为
TABLE\u
。下面是一个例子:

根据,应在类层次结构的根上指定
@heritation
注释:

SubSub -> Sub -> Base
定义要用于实体类的继承策略 等级制度它是在实体类上指定的,实体类是 实体类层次结构

如果此注释可以放置在子类上,并且其行为未定义,则规范未指定此注释

因此,要回答您在评论中提出的问题,如果您有此层次结构:

SubSub -> Sub -> Base

您只需要使用
@heritance(strategy=TABLE\u PER\u CLASS)
注释
Base
,那么继承人制度中的所有超类都必须具有相同的@heritance注释吗?如果没有,那么使用不同的注释意味着什么?