Customer.java
2.11 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
package com.PFE.ServerManager;
import javax.persistence.*;
import java.util.Set;
@Entity
@Table(name = "customer") // NE PAS utiliser "User" car c'est un mot clef réservé pour PostgreSQL
public class Customer{
@Id
//@GeneratedValue(strategy=GenerationType.AUTO)
@Column(columnDefinition = "serial")
/*la méthode ci-dessous oblige à connaitre le nombre de lignes déjà présentes dans la table customer au lancement du programme*/
/*@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "customer_seq_gen")
@SequenceGenerator(name = "customer_seq_gen", sequenceName = "customer_id_seq", allocationSize=1, initialValue=3)*/
@Basic(optional = false)
private Integer customer_id;
@Column(name = "email")
private String email;
@Column(name = "password")
private String password;
@Column(name = "active")
private int active;
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "customer_role", joinColumns = @JoinColumn(name = "customer_id"), inverseJoinColumns = @JoinColumn(name = "role_id"))
private Set<Role> roles;
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "customer_maj", joinColumns = @JoinColumn(name = "customer_id"), inverseJoinColumns = @JoinColumn(name = "maj_id"))
private Set<Maj> maj;
public void setRoles(Set<Role> roles) { this.roles = roles; }
public Set<Role> getRoles() { return roles; }
public void setMaj(Set<Maj> maj) {
this.maj = maj;
}
public Set<Maj> getMaj() {
return maj;
}
public String getRole(){
return roles.iterator().next().getRole();
}
public void setId(Integer id) {
this.customer_id = id;
}
public Integer getCustomer_id() { return customer_id; }
public void setEmail(String email) {
this.email = email;
}
public String getEmail() { return email; }
public void setPassword(String password) {
this.password = password;
}
public String getPassword() { return password; }
public void setActive(int active) { this.active = active; }
public int getActive() { return active; }
}