@Entity
@Table(name = "a")
@Inheritance(strategy = SINGLE_TABLE)
@DiscriminatorColumn(name = "b_or_c", discriminatorType = DiscriminatorType.STRING)
public abstract class A {
@Id
@GeneratedValue(strategy = IDENTITY)
private long id;
...
@OneToMany(mappedBy = "a")
private Collection<X> x;
@ManyToOne
@JoinColumn(name = "y_id")
private Y y;
@ManyToOne(optional = false)
@JoinColumn(name = "z_id")
private Z z;
}
@Entity
@DiscriminatorValue("b")
public class B extends A {
@ManyToOne
@JoinColumn(name = "l_id")
private L l;
@ManyToOne
@JoinColumn(name = "m_id")
private M m;
@ManyToOne
@JoinColumn(name = "n_id")
private N n;
}