SpringBoot Data JPA实体继承

版权声明:本文为博主书香代码原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010138825/article/details/83109321

关于实体继承解决方式

参考:https://github.com/spring-projects/spring-data-book/blob/master/jpa/src/main/java/com/oreilly/springdata/jpa/core/AbstractEntity.java

@MappedSuperclass
public class AbstractEntity{
  //子类都需要的字段可写在这里
   @Column(length = 6)
   private String name;
   ... ...
}


@Entity
@Table(name = "child")
public class ChildEntity extends AbstractEntity{
... ...
}

主键策略可参考:
https://blog.csdn.net/MJZ_CSDN/article/details/45024499?utm_source=blogxgwz1
https://blog.csdn.net/cooledi/article/details/78182135?utm_source=blogxgwz1

猜你喜欢

转载自blog.csdn.net/u010138825/article/details/83109321
今日推荐