/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
*
* You may not modify, use, reproduce, or distribute this software
* except in compliance with the terms of the license at:
* http://developer.sun.com/berkeley_license.html
*/
package entity;
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;
/**
*
* @author tgiunipero
*/
@Entity
@Table(name = "customer")
@NamedQueries({
@NamedQuery(name = "Customer.findAll", query = "SELECT c FROM Customer c"),
@NamedQuery(name = "Customer.findById", query = "SELECT c FROM Customer c WHERE c.id = :id"),
@NamedQuery(name = "Customer.findByName", query = "SELECT c FROM Customer c WHERE c.name = :name"),
@NamedQuery(name = "Customer.findByEmail", query = "SELECT c FROM Customer c WHERE c.email = :email"),
@NamedQuery(name = "Customer.findByPhone", query = "SELECT c FROM Customer c WHERE c.phone = :phone"),
@NamedQuery(name = "Customer.findByAddress", query = "SELECT c FROM Customer c WHERE c.address = :address"),
@NamedQuery(name = "Customer.findByCityRegion", query = "SELECT c FROM Customer c WHERE c.cityRegion = :cityRegion"),
@NamedQuery(name = "Customer.findByCcNumber", query = "SELECT c FROM Customer c WHERE c.ccNumber = :ccNumber")})
public class Customer implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "id")
private Integer id;
@Basic(optional = false)
@Column(name = "name")
private String name;
@Basic(optional = false)
@Column(name = "email")
private String email;
@Basic(optional = false)
@Column(name = "phone")
private String phone;
@Basic(optional = false)
@Column(name = "address")
private String address;
@Basic(optional = false)
@Column(name = "city_region")
private String cityRegion;
@Basic(optional = false)
@Column(name = "cc_number")
private String ccNumber;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "customer")
private Collection<CustomerOrder> customerOrderCollection;
public Customer() {
}
public Customer(Integer id) {
this.id = id;
}
public Customer(Integer id, String name, String email, String phone, String address, String cityRegion, String ccNumber) {
this.id = id;
this.name = name;
this.email = email;
this.phone = phone;
this.address = address;
this.cityRegion = cityRegion;
this.ccNumber = ccNumber;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCityRegion() {
return cityRegion;
}
public void setCityRegion(String cityRegion) {
this.cityRegion = cityRegion;
}
public String getCcNumber() {
return ccNumber;
}
public void setCcNumber(String ccNumber) {
this.ccNumber = ccNumber;
}
public Collection<CustomerOrder> getCustomerOrderCollection() {
return customerOrderCollection;
}
public void setCustomerOrderCollection(Collection<CustomerOrder> customerOrderCollection) {
this.customerOrderCollection = customerOrderCollection;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.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.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "entity.Customer[id=" + id + "]";
}
}