我有两个类Participant和TimeWindow。多个参与者可以注册多个 TimeWindow,因此存在 ManyToMany 关系
@Entity
@Table
public class Participant {
@Id
@SequenceGenerator(
name = "participant_sequence",
sequenceName = "particant_sequence",
allocationSize = 1
)
@GeneratedValue(
strategy = GenerationType.SEQUENCE,
generator = "participant_sequence"
)
private Long id;
private String name;
private String number;
private String details;
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "ParticipantCreneaux")
private Collection<TimeWindow> registeredTimeWindow;
public Participant() {
}
public Participant(String nom, String num, String details) {
this.name = nom;
this.number = num;
this.details = details;
this.registeredTimeWindow = new ArrayList<>(); …Run Code Online (Sandbox Code Playgroud)