У меня две таблицы по отношению многие ко многим
public class Repertoire {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(nullable = false, unique = true)
private Integer id;
private String name;
private Integer dayWeek;
@ManyToMany(cascade = CascadeType.REMOVE)
@JoinTable(
name = "repertoire_seance",
joinColumns = { @JoinColumn(name = "repertoire_id")},
inverseJoinColumns = {@JoinColumn(name = "seance_id")}
)
List<Seance> seances = new ArrayList<>();
}
и
public class Seance {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(nullable = false, unique = true)
private Integer id;
private java.time.LocalTime displayTime;
@ManyToOne
private Film film;
@Column(length=127)
private String kind;
@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
private Hall hall;
@OneToMany(mappedBy = "reservationSeance")
@JsonIgnore
private List<Reservation> reservations = new ArrayList<>();
}
Hibernate создать связанную табличку