Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import java.util.HashSet;
  2. import java.util.Set;
  3. import javax.persistence.CascadeType;
  4. import javax.persistence.Column;
  5. import javax.persistence.Entity;
  6. import javax.persistence.FetchType;
  7. import javax.persistence.GeneratedValue;
  8. import static javax.persistence.GenerationType.IDENTITY;
  9. import javax.persistence.Id;
  10. import javax.persistence.OneToMany;
  11. import javax.persistence.Table;
  12. import javax.persistence.UniqueConstraint;
  13.  
  14. @Entity
  15. @Table(name = "escuela", catalog = "matriculadelaboratorio", uniqueConstraints =
  16. @UniqueConstraint(columnNames = "codigo"))
  17. public class Escuela implements java.io.Serializable {
  18.  
  19.     private Integer idEscuela;
  20.     private String codigo;
  21.     private String nombre;
  22.     private boolean estado;
  23.     private Set<Curso> cursos = new HashSet<Curso>(0);
  24.  
  25.     public Escuela() {
  26.     }
  27.  
  28.     public Escuela(String codigo, String nombre, boolean estado) {
  29.         this.codigo = codigo;
  30.         this.nombre = nombre;
  31.         this.estado = estado;
  32.     }
  33.  
  34.     public Escuela(String codigo, String nombre, boolean estado, Set<Curso> cursos) {
  35.         this.codigo = codigo;
  36.         this.nombre = nombre;
  37.         this.estado = estado;
  38.         this.cursos = cursos;
  39.     }
  40.  
  41.     @Id
  42.     @GeneratedValue(strategy = IDENTITY)
  43.     @Column(name = "idEscuela", unique = true, nullable = false)
  44.     public Integer getIdEscuela() {
  45.         return this.idEscuela;
  46.     }
  47.  
  48.     public void setIdEscuela(Integer idEscuela) {
  49.         this.idEscuela = idEscuela;
  50.     }
  51.  
  52.     @Column(name = "codigo", unique = true, nullable = false, length = 2)
  53.     public String getCodigo() {
  54.         return this.codigo;
  55.     }
  56.  
  57.     public void setCodigo(String codigo) {
  58.         this.codigo = codigo;
  59.     }
  60.  
  61.     @Column(name = "nombre", nullable = false, length = 45)
  62.     public String getNombre() {
  63.         return this.nombre;
  64.     }
  65.  
  66.     public void setNombre(String nombre) {
  67.         this.nombre = nombre;
  68.     }
  69.  
  70.     @Column(name = "estado", nullable = false)
  71.     public boolean isEstado() {
  72.         return this.estado;
  73.     }
  74.  
  75.     public void setEstado(boolean estado) {
  76.         this.estado = estado;
  77.     }
  78.  
  79.     @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "escuela")
  80.     public Set<Curso> getCursos() {
  81.         return this.cursos;
  82.     }
  83.  
  84.     public void setCursos(Set<Curso> cursos) {
  85.         this.cursos = cursos;
  86.     }
  87.  
  88.     @Override
  89.     public int hashCode() {
  90.         int hash = 0;
  91.         hash += (idEscuela != null ? idEscuela.hashCode() : 0);
  92.         return hash;
  93.     }
  94.  
  95.     @Override
  96.     public boolean equals(Object object) {
  97.         // TODO: Warning - this method won't work in the case the id fields are not set
  98.         if (!(object instanceof Escuela)) {
  99.             return false;
  100.         }
  101.         Escuela other = (Escuela) object;
  102.         if ((this.idEscuela == null && other.idEscuela != null) || (this.idEscuela != null && !this.idEscuela.equals(other.idEscuela))) {
  103.             return false;
  104.         }
  105.         return true;
  106.     }
  107. }