Guest
Public paste!

EIS - JF

By: a guest | Mar 21st, 2010 | Syntax: None | Size: 2.92 KB | Hits: 63 | Expires: Never
This paste has a previous version, view the difference. Copy text to clipboard
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5.  
  6. package entities;
  7.  
  8. import java.io.Serializable;
  9. import javax.persistence.CascadeType;
  10. import javax.persistence.Column;
  11. import javax.persistence.Entity;
  12. import javax.persistence.GeneratedValue;
  13. import javax.persistence.GenerationType;
  14. import javax.persistence.Id;
  15. import javax.persistence.JoinColumn;
  16. import javax.persistence.ManyToOne;
  17. import javax.persistence.OneToOne;
  18.  
  19. /**
  20.  *
  21.  * @author juanfelipe
  22.  */
  23. @Entity
  24. public class Student implements Serializable {
  25.     private static final long serialVersionUID = 1L;
  26.     @Id
  27.     @GeneratedValue(strategy = GenerationType.IDENTITY)
  28.     private Long id;
  29.     @Column(length=45, nullable=false)
  30.     private String name;
  31.     @Column(length=12, nullable=false)
  32.     private String identification;
  33.     @Column(length=12)
  34.     private String phone;
  35.     @Column(length=45)
  36.     private String email;
  37.  
  38.     @OneToOne(cascade = CascadeType.ALL)
  39.     private Address address;
  40.  
  41.     @ManyToOne
  42.     @JoinColumn(name="PROGRAM_ID")
  43.     private Program programa;
  44.  
  45.     public void setProgram(Program program) {
  46.         this.programa = program;
  47.     }
  48.  
  49.     public Program getProgram() {
  50.         return programa;
  51.     }
  52.  
  53.     public Address getAddress() {
  54.         return address;
  55.     }
  56.  
  57.     public static long getSerialVersionUID() {
  58.         return serialVersionUID;
  59.     }
  60.  
  61.     public void setAddress(Address address) {
  62.         this.address = address;
  63.     }
  64.  
  65.     public String getEmail() {
  66.         return email;
  67.     }
  68.  
  69.     public String getIdentification() {
  70.         return identification;
  71.     }
  72.  
  73.     public String getName() {
  74.         return name;
  75.     }
  76.  
  77.     public String getPhone() {
  78.         return phone;
  79.     }
  80.  
  81.     public Long getId() {
  82.         return id;
  83.     }
  84.  
  85.     public void setName(String name) {
  86.         this.name = name;
  87.     }
  88.  
  89.     public void setEmail(String email) {
  90.         this.email = email;
  91.     }
  92.  
  93.     public void setIdentification(String identification) {
  94.         this.identification = identification;
  95.     }
  96.  
  97.     public void setPhone(String phone) {
  98.         this.phone = phone;
  99.     }
  100.  
  101.     public void setId(Long id) {
  102.         this.id = id;
  103.     }
  104.  
  105.     @Override
  106.     public int hashCode() {
  107.         int hash = 0;
  108.         hash += (id != null ? id.hashCode() : 0);
  109.         return hash;
  110.     }
  111.  
  112.     @Override
  113.     public boolean equals(Object object) {
  114.         // TODO: Warning - this method won't work in the case the id fields are not set
  115.         if (!(object instanceof Student)) {
  116.             return false;
  117.         }
  118.         Student other = (Student) object;
  119.         if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
  120.             return false;
  121.         }
  122.         return true;
  123.     }
  124.  
  125.     @Override
  126.     public String toString() {
  127.         return "entities.Student[id=" + id + "]";
  128.     }
  129.  
  130. }