-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathSpeaker.java
More file actions
39 lines (29 loc) · 945 Bytes
/
Speaker.java
File metadata and controls
39 lines (29 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package io.bcn.springConference.model;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
import java.util.UUID;
@Data
@Entity
@Table(name = "speakers")
@NoArgsConstructor
@AllArgsConstructor
public class Speaker {
@Id
//@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", updatable = false,
nullable = false)
private UUID id;
@Column(name = "name",nullable = false)
private String name;
@OneToMany(mappedBy = "speakerMapped", cascade = CascadeType.ALL)
private List<Conference> conferences;
//method to add
public void addConference(Conference conference) {
this.getConferences().add(conference);
if (conference.getSpeakerMapped() != null) conference.getSpeakerMapped().getConferences().remove(conference);
conference.setSpeakerMapped(this);
}
}