These are my classes:
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class BaseEntity<T> implements Serializable {
@Id
@Column(name = "id", unique = true, nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO)
private T id;
}
@Entity
@Table(name = "core_users")
@Inheritance(strategy = InheritanceType.JOINED)
public class User extends BaseEntity<Long> implements UserDetails {
}
@Entity
@Table(name = "app_customers")
public class BaseCustomer extends User {
@OneToOne(mappedBy = "owner", cascade = CascadeType.ALL)
private Address address;
}
@Entity
@Table(name = "app_address")
public class Address extends BaseEntity<Long> {
@Id
@Column(name = "id", unique = true, nullable = false)
@GeneratedValue(generator = "gen")
@GenericGenerator(name = "gen", strategy = "foreign", parameters = @Parameter(name = "property", value = "owner"))
private Long id;
@OneToOne
@PrimaryKeyJoinColumn
private BaseCustomer owner;
}
When i start the application to create table, in create table but does not create foreign keys in app_customers
and app_address
.
Joneid inheritance is not using foreign keys. Read more: https://en.wikibooks.org/wiki/Java_Persistence/Inheritance#Joined.2C_Multiple_Table_Inheritance