Java- JPA @Entity 和@Embeddable 在一起

Java- JPA @Entity and @Embeddable together

我是 Spring jpa 的新手,我有一个需要创建的用例:

Table A :包含列 'a' 、 'b' 和 'c'

A​​nd Table B :使用列 'd' 以及 Table A[= 中的列28=].

我的问题是,

我可以用 @Entity[=31= 为 Table A 注释 POJO ] 和 @Embeddable ?

您必须按名称放置两个注释 @Embeddable@MappedSuperclass 在 table A 实体上方,您还必须将 table A 实体继承到 table B 实体中,如下所示。

@Embeddable
@MappedSuperclass
@Entity
class TableA{....}

@Entity
Class TableB extends TableA{...}