- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package entities;
- import java.io.Serializable;
- 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.JoinColumn;
- import javax.persistence.ManyToOne;
- import javax.persistence.OneToOne;
- /**
- *
- * @author juanfelipe
- */
- @Entity
- public class Student implements Serializable {
- private static final long serialVersionUID = 1L;
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Long id;
- @Column(length=45, nullable=false)
- private String name;
- @Column(length=12, nullable=false)
- private String identification;
- @Column(length=12)
- private String phone;
- @Column(length=45)
- private String email;
- @OneToOne(cascade = CascadeType.ALL)
- private Address address;
- @ManyToOne
- @JoinColumn(name="PROGRAM_ID")
- private Program programa;
- public void setProgram(Program program) {
- this.programa = program;
- }
- public Program getProgram() {
- return programa;
- }
- public Address getAddress() {
- return address;
- }
- public static long getSerialVersionUID() {
- return serialVersionUID;
- }
- public void setAddress(Address address) {
- this.address = address;
- }
- public String getEmail() {
- return email;
- }
- public String getIdentification() {
- return identification;
- }
- public String getName() {
- return name;
- }
- public String getPhone() {
- return phone;
- }
- public Long getId() {
- return id;
- }
- public void setName(String name) {
- this.name = name;
- }
- public void setEmail(String email) {
- this.email = email;
- }
- public void setIdentification(String identification) {
- this.identification = identification;
- }
- public void setPhone(String phone) {
- this.phone = phone;
- }
- public void setId(Long id) {
- this.id = id;
- }
- @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 Student)) {
- return false;
- }
- Student other = (Student) 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 "entities.Student[id=" + id + "]";
- }
- }
