JPA. How do I subclass existing entity and keep its ID?

后端 未结 2 2111
囚心锁ツ
囚心锁ツ 2021-02-14 08:19

Assume I have two classic non-abstract JPA classes: Person and Student.

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class Person {
  @Id
  @Ge         


        
2条回答
  •  南旧
    南旧 (楼主)
    2021-02-14 09:05

    As far as I know, there are no good ways to achieve it.

    It would be much simplier if you model this situation as a Person that can have multiple roles Roles (one-to-many relationship), where Student is one of them (i.e. Student extends Role).

提交回复
热议问题