package miage.ecom.entity;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author Lou
*/
@Entity
@Table(name = "customer")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Customer.findAll", query = "SELECT c FROM Customer c"),
@NamedQuery(name = "Customer.findByIdCustomer", query = "SELECT c FROM Customer c WHERE c.idCustomer = :idCustomer"),
@NamedQuery(name = "Customer.findByLogin", query = "SELECT c FROM Customer c WHERE c.login = :login"),
@NamedQuery(name = "Customer.findByPassword", query = "SELECT c FROM Customer c WHERE c.password = :password"),
@NamedQuery(name = "Customer.findByLastname", query = "SELECT c FROM Customer c WHERE c.lastname = :lastname"),
@NamedQuery(name = "Customer.findByFirstname", query = "SELECT c FROM Customer c WHERE c.firstname = :firstname"),
@NamedQuery(name = "Customer.findByAddress", query = "SELECT c FROM Customer c WHERE c.address = :address"),
@NamedQuery(name = "Customer.findByCredentials", query = "SELECT c FROM Customer c WHERE c.login = :login AND c.password = :password")
})
public class Customer implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Basic(optional = false)
@Column(name = "id_customer", unique = true, nullable = false)
private Integer idCustomer;
@Size(max = 45)
@Column(name = "login")
private String login;
@Size(max = 45)
@Column(name = "password")
private String password;
@Size(max = 45)
@Column(name = "lastname")
private String lastname;
@Size(max = 45)
@Column(name = "firstname")
private String firstname;
@Size(max = 200)
@Column(name = "address")
private String address;
@JoinColumn(name = "id_account", referencedColumnName = "id_account")
@ManyToOne(optional = false)
private Account idAccount;
public Customer() {
}
public Customer(Integer idCustomer) {
this.idCustomer = idCustomer;
}
public Integer getIdCustomer() {
return idCustomer;
}
public void setIdCustomer(Integer idCustomer) {
this.idCustomer = idCustomer;
}
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 getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public Account getIdAccount() {
return idAccount;
}
public void setIdAccount(Account idAccount) {
this.idAccount = idAccount;
}
@Override
public int hashCode() {
int hash = 0;
hash += (idCustomer != null ? idCustomer.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 Customer)) {
return false;
}
Customer other = (Customer) object;
if ((this.idCustomer == null && other.idCustomer != null) || (this.idCustomer != null && !this.idCustomer.equals(other.idCustomer))) {
return false;
}
return true;
}
@Override
public String toString() {
return "miage.ecom.entity.Customer[ idCustomer=" + idCustomer + " ]";
}
}