Team.java
1.91 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package com.PFE.ServerManager;
import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;
@Entity
@Table(name = "team")
public class Team {
@Id
@Column(columnDefinition = "serial")
//@GeneratedValue(strategy = GenerationType.AUTO)
@Basic(optional = false)
private Integer teamId;
@Column(name = "teamName")
private String team;
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "team_update", joinColumns = @JoinColumn(name = "teamId"), inverseJoinColumns = @JoinColumn(name = "updateId"))
private Set<Update> updates;
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "team_customer", joinColumns = @JoinColumn(name = "teamId"), inverseJoinColumns = @JoinColumn(name = "customerId"))
private Set<Customer> customers;
public void setTeam(String team) {
this.team = team;
}
public String getTeam() {
return team;
}
public void setTeamId(Integer teamId) {
this.teamId = teamId;
}
public Integer getTeamId() {
return teamId;
}
public void setCustomers(Set<Customer> customers) {
this.customers = customers;
}
public Set<Customer> getCustomers() {
return customers;
}
public void addCustomer(Customer customer){
if(customers == null){
customers = new HashSet<>();
}
this.customers.add(customer);
}
public void removeCustomer(Customer customer){
if(customers != null){
customers.remove(customer);
}
}
public void setUpdates(Set<Update> updates) {
this.updates = updates;
}
public Set<Update> getUpdates() {
return updates;
}
public void addUpdate(Update update){
if(updates == null) {
updates = new HashSet<>();
}
this.updates.add(update);
}
}