Advertisement
Guest User

celalo

a guest
Jan 2nd, 2010
838
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.33 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5.  
  6. package javaapplication3;
  7.  
  8. import java.io.Serializable;
  9. import java.util.Collection;
  10. import javax.persistence.Basic;
  11. import javax.persistence.CascadeType;
  12. import javax.persistence.Column;
  13. import javax.persistence.Entity;
  14. import javax.persistence.GeneratedValue;
  15. import javax.persistence.GenerationType;
  16. import javax.persistence.Id;
  17. import javax.persistence.NamedQueries;
  18. import javax.persistence.NamedQuery;
  19. import javax.persistence.OneToMany;
  20. import javax.persistence.Table;
  21.  
  22. /**
  23.  *
  24.  * @author celalo
  25.  */
  26. @Entity
  27. @Table(name = "customer")
  28. @NamedQueries({
  29.     @NamedQuery(name = "Customer.findAll", query = "SELECT c FROM Customer c"),
  30.     @NamedQuery(name = "Customer.findById", query = "SELECT c FROM Customer c WHERE c.id = :id"),
  31.     @NamedQuery(name = "Customer.findByIdentification", query = "SELECT c FROM Customer c WHERE c.identification = :identification")})
  32. public class Customer implements Serializable {
  33.     private static final long serialVersionUID = 1L;
  34.     @Id
  35.     @GeneratedValue(strategy = GenerationType.IDENTITY)
  36.     @Basic(optional = false)
  37.     @Column(name = "id")
  38.     private Integer id;
  39.     @Column(name = "identification")
  40.     private String identification;
  41.     @OneToMany(cascade = CascadeType.ALL, mappedBy = "customerId")
  42.     private Collection<InsuranceAgent> insuranceAgentCollection;
  43.     @OneToMany(cascade = CascadeType.ALL, mappedBy = "customerId")
  44.     private Collection<InsuranceVehicleOwner> insuranceVehicleOwnerCollection;
  45.  
  46.     public Customer() {
  47.     }
  48.  
  49.     public Customer(Integer id) {
  50.         this.id = id;
  51.     }
  52.  
  53.     public Integer getId() {
  54.         return id;
  55.     }
  56.  
  57.     public void setId(Integer id) {
  58.         this.id = id;
  59.     }
  60.  
  61.     public String getIdentification() {
  62.         return identification;
  63.     }
  64.  
  65.     public void setIdentification(String identification) {
  66.         this.identification = identification;
  67.     }
  68.  
  69.     public Collection<InsuranceAgent> getInsuranceAgentCollection() {
  70.         return insuranceAgentCollection;
  71.     }
  72.  
  73.     public void setInsuranceAgentCollection(Collection<InsuranceAgent> insuranceAgentCollection) {
  74.         this.insuranceAgentCollection = insuranceAgentCollection;
  75.     }
  76.  
  77.     public Collection<InsuranceVehicleOwner> getInsuranceVehicleOwnerCollection() {
  78.         return insuranceVehicleOwnerCollection;
  79.     }
  80.  
  81.     public void setInsuranceVehicleOwnerCollection(Collection<InsuranceVehicleOwner> insuranceVehicleOwnerCollection) {
  82.         this.insuranceVehicleOwnerCollection = insuranceVehicleOwnerCollection;
  83.     }
  84.  
  85.     @Override
  86.     public int hashCode() {
  87.         int hash = 0;
  88.         hash += (id != null ? id.hashCode() : 0);
  89.         return hash;
  90.     }
  91.  
  92.     @Override
  93.     public boolean equals(Object object) {
  94.         // TODO: Warning - this method won't work in the case the id fields are not set
  95.         if (!(object instanceof Customer)) {
  96.             return false;
  97.         }
  98.         Customer other = (Customer) object;
  99.         if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
  100.             return false;
  101.         }
  102.         return true;
  103.     }
  104.  
  105.     @Override
  106.     public String toString() {
  107.         return "javaapplication3.Customer[id=" + id + "]";
  108.     }
  109.  
  110. }
  111.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement