Java- JPA @Entity和@Embeddable在一起

问题描述 投票:1回答:1

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

表A:带有列'a','b'和'c'

表B:具有列d和表A中的列。

我的问题是,

我可以用@ Entity@ Embeddable都为Table A注释POJO吗?

java jpa spring-data-jpa persistence persistent
1个回答
0
投票
You will have to put two annotation by name "@Embeddable And
@MappedSuperclass" on above the table A entity and also you will have to inherit table A entity into the table B entity like below.

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

@Entity
Class TableB extends TableA{...}
© www.soinside.com 2019 - 2024. All rights reserved.