简体   繁体   English

Liquibase变更集中的继承

[英]Inheritance in liquibase changeset

I am using inheritance concept in my application. 我在我的应用程序中使用继承概念。

The parent class: 父类:

@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "NATURE_PERSONNE", discriminatorType =  DiscriminatorType.STRING, length = 4)
@Table(name = "PERSONNE")
public class Personne extends AuditingEntity implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID")
    private Long id;

    @Column(name = "NOM")
    private String nom;

    @Column(name = "PRENOM")
    private String prenom;
        ...
  }

The child class: 子班:

@Entity
@DiscriminatorValue("EMPL")
public class Employeur extends Personne {

    @Column(name = "DATE_DEBUT_TRAVAIL")
    private LocalDate dateDebutTravail;

    @Column(name = "EMPLOI")
    private String emploi;
    ....
}

Is there a possibility of creating inheritance structure in Liquibase. 是否有可能在Liquibase中创建继承结构。 How do it ? 怎么了

Thanks. 谢谢。

Basically liquibase doesn't care about inheritance. 基本上liquibase不在乎继承。 It only cares about database structures such as schemata, tables and indexes. 它只关心数据库结构,例如模式,表和索引。

That is if you want to let liquibase create the table(s) for your two entity classes, you will need to figure out what JPA expects these tables to look like and write the matching liquibase statements. 就是说,如果您想让liquibase为您的两个实体类创建表,则需要弄清楚JPA希望这些表看起来像什么,并编写匹配的liquibase语句。 Without knowing AuditingEntity I can't provide the exact statement but basically you will end up with a single table PERSONNE with all the attributes of Personne and Employeur . 在不知道AuditingEntity我无法提供确切的陈述,但基本上,您最终将得到一个具有PersonneEmployeur所有属性的表格PERSONNE

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM