拥有一个抽象且没有鉴别器的顶级JPA类合法吗?

拥有一个抽象且没有鉴别器的顶级JPA类合法吗?,jpa,Jpa,例如,以下顶级JPA类是否有效: @Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorColumn( name = "type", discriminatorType = DiscriminatorType.STRING ) public abstract class Person implements Serializable { @Id @GeneratedVa

例如,以下顶级JPA类是否有效:

@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(
    name = "type",
    discriminatorType = DiscriminatorType.STRING
)
public abstract class Person implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    public Long getId() {
        return id;
    }
}

我没有理由不这样做。试试看

如果规范中描述的实体上未指定鉴别器值注释,则指定鉴别器列的鉴别器值将是具体实现的实体名称


这回答了你的问题吗?

是的,这是完全合法的。根据规范JPA 2.0 DiscriminatorValue只属于具体的实体类。

不太可能。我正在寻找一个明确的答案。