/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package entities; import java.io.Serializable; import java.util.Collection; import javax.persistence.Basic; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.OneToMany; import javax.persistence.Table; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; /** * * @author Drake */ @XmlRootElement @Entity @Table(name = "utilisateur", catalog = "annonce", schema = "") @NamedQueries({ @NamedQuery(name = "Utilisateur.findAll", query = "SELECT u FROM Utilisateur u"), @NamedQuery(name = "Utilisateur.findByIdutilisateur", query = "SELECT u FROM Utilisateur u WHERE u.idutilisateur = :idutilisateur"), @NamedQuery(name = "Utilisateur.findByNom", query = "SELECT u FROM Utilisateur u WHERE u.nom = :nom"), @NamedQuery(name = "Utilisateur.findByPrenom", query = "SELECT u FROM Utilisateur u WHERE u.prenom = :prenom"), @NamedQuery(name = "Utilisateur.findByNumero", query = "SELECT u FROM Utilisateur u WHERE u.numero = :numero"), @NamedQuery(name = "Utilisateur.findByAdresse", query = "SELECT u FROM Utilisateur u WHERE u.adresse = :adresse"), @NamedQuery(name = "Utilisateur.findByEmail", query = "SELECT u FROM Utilisateur u WHERE u.email = :email"), @NamedQuery(name = "Utilisateur.findByVille", query = "SELECT u FROM Utilisateur u WHERE u.ville = :ville"), @NamedQuery(name = "Utilisateur.findByRegion", query = "SELECT u FROM Utilisateur u WHERE u.region = :region"), @NamedQuery(name = "Utilisateur.findByPays", query = "SELECT u FROM Utilisateur u WHERE u.pays = :pays"), @NamedQuery(name = "Utilisateur.findBySexe", query = "SELECT u FROM Utilisateur u WHERE u.sexe = :sexe"), @NamedQuery(name = "Utilisateur.findByLogin", query = "SELECT u FROM Utilisateur u WHERE u.login = :login"), @NamedQuery(name = "Utilisateur.findByPassword", query = "SELECT u FROM Utilisateur u WHERE u.password = :password"), @NamedQuery(name = "Utilisateur.findByRole", query = "SELECT u FROM Utilisateur u WHERE u.role = :role")}) public class Utilisateur implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Basic(optional = false) @Column(name = "idutilisateur", nullable = false) private Integer idutilisateur; @Basic(optional = false) @NotNull @Size(min = 1, max = 45) @Column(name = "nom", nullable = false, length = 45) private String nom; @Basic(optional = false) @NotNull @Size(min = 1, max = 45) @Column(name = "prenom", nullable = false, length = 45) private String prenom; @Basic(optional = false) @NotNull @Size(min = 1, max = 45) @Column(name = "numero", nullable = false, length = 45) private String numero; @Basic(optional = false) @NotNull @Size(min = 1, max = 45) @Column(name = "adresse", nullable = false, length = 45) private String adresse; // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation @Basic(optional = false) @NotNull @Size(min = 1, max = 45) @Column(name = "email", nullable = false, length = 45) private String email; @Basic(optional = false) @NotNull @Size(min = 1, max = 45) @Column(name = "ville", nullable = false, length = 45) private String ville; @Basic(optional = false) @NotNull @Size(min = 1, max = 45) @Column(name = "region", nullable = false, length = 45) private String region; @Basic(optional = false) @NotNull @Size(min = 1, max = 45) @Column(name = "pays", nullable = false, length = 45) private String pays; @Basic(optional = false) @NotNull @Size(min = 1, max = 45) @Column(name = "sexe", nullable = false, length = 45) private String sexe; @Basic(optional = false) @NotNull @Size(min = 1, max = 45) @Column(name = "login", nullable = false, length = 45) private String login; @Basic(optional = false) @NotNull @Size(min = 1, max = 45) @Column(name = "password", nullable = false, length = 45) private String password; @Basic(optional = false) @NotNull @Size(min = 1, max = 45) @Column(name = "role", nullable = false, length = 45) private String role; @OneToMany(cascade = CascadeType.ALL, mappedBy = "idutilisateur") private Collection annonceCollection; public Utilisateur() { } public Utilisateur(Integer idutilisateur) { this.idutilisateur = idutilisateur; } public Utilisateur(Integer idutilisateur, String nom, String prenom, String numero, String adresse, String email, String ville, String region, String pays, String sexe, String login, String password, String role) { this.idutilisateur = idutilisateur; this.nom = nom; this.prenom = prenom; this.numero = numero; this.adresse = adresse; this.email = email; this.ville = ville; this.region = region; this.pays = pays; this.sexe = sexe; this.login = login; this.password = password; this.role = role; } public Integer getIdutilisateur() { return idutilisateur; } public void setIdutilisateur(Integer idutilisateur) { this.idutilisateur = idutilisateur; } public String getNom() { return nom; } public void setNom(String nom) { this.nom = nom; } public String getPrenom() { return prenom; } public void setPrenom(String prenom) { this.prenom = prenom; } public String getNumero() { return numero; } public void setNumero(String numero) { this.numero = numero; } public String getAdresse() { return adresse; } public void setAdresse(String adresse) { this.adresse = adresse; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getVille() { return ville; } public void setVille(String ville) { this.ville = ville; } public String getRegion() { return region; } public void setRegion(String region) { this.region = region; } public String getPays() { return pays; } public void setPays(String pays) { this.pays = pays; } public String getSexe() { return sexe; } public void setSexe(String sexe) { this.sexe = sexe; } public String getLogin() { return login; } public void setLogin(String login) { this.login = login; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getRole() { return role; } public void setRole(String role) { this.role = role; } @XmlTransient public Collection getAnnonceCollection() { return annonceCollection; } public void setAnnonceCollection(Collection annonceCollection) { this.annonceCollection = annonceCollection; } @Override public int hashCode() { int hash = 0; hash += (idutilisateur != null ? idutilisateur.hashCode() : 0); return hash; } @Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Utilisateur)) { return false; } Utilisateur other = (Utilisateur) object; if ((this.idutilisateur == null && other.idutilisateur != null) || (this.idutilisateur != null && !this.idutilisateur.equals(other.idutilisateur))) { return false; } return true; } @Override public String toString() { return "entities.Utilisateur[ idutilisateur=" + idutilisateur + " ]"; } }