Reputation: 495
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. How do it ?
Thanks.
Upvotes: 1
Views: 2222
Reputation: 10964
Basically liquibase doesn't care about inheritance. 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. 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
.
Upvotes: 1