Общая таблица
Содержит одно-много отображений
@Entity
@Table(name= "common")
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
property = "id",
scope = Long.class)
@DynamicInsert(true)
@DynamicUpdate(true)
public class Common implements Serializable {
private static final long serialVersionUID = 6953927535242022811L;
@Id
@Column(name= "id")
private Long id = Long.parseLong(UUID.randomUUID().toString().substring(0, 8), 16);
@OneToMany(cascade= CascadeType.ALL, mappedBy= "a_id", orphanRemoval= true )
@LazyCollection(LazyCollectionOption.FALSE)
private List<A> aList;
@OneToMany(cascade= CascadeType.ALL, mappedBy= "b_id", orphanRemoval= true )
@LazyCollection(LazyCollectionOption.FALSE)
private List<B> bList;
@OneToMany(cascade= CascadeType.ALL, mappedBy= "c_id", orphanRemoval= true )
@LazyCollection(LazyCollectionOption.FALSE)
private List<C> cList;
// getter and setters
}
Таблица A
@Entity
@Table(name= "a")
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
property = "id",
scope = Long.class)
@DynamicInsert(true)
@DynamicUpdate(true)
public class A implements Serializable {
private static final long serialVersionUID = 6953927535242022811L;
@Id
@Column(name= "id")
private Long id = Long.parseLong(UUID.randomUUID().toString().substring(0, 8), 16);
@ManyToOne(optional=false)
@JoinColumn(name= "common_id")
private Common CommonId; //many to one is option if you required
}
аналогичная реализация для B и C