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 customerId; @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 = "customerId"), inverseJoinColumns = @JoinColumn(name = "roleId")) private Set roles; @ManyToMany(cascade = CascadeType.ALL) @JoinTable(name = "customer_update", joinColumns = @JoinColumn(name = "customerId"), inverseJoinColumns = @JoinColumn(name = "updateId")) private Set update; public void setRoles(Set roles) { this.roles = roles; } public Set getRoles() { return roles; } public void setUpdate(Set update) { this.update = update; } public Set getUpdate() { return update; } public String getRole(){ return roles.iterator().next().getRole(); } public void setId(Integer id) { this.customerId = id; } public Integer getCustomerId() { return customerId; } 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; } }