|
| 1 | +package unit15.jpa.Actividad20_Aplicacion; |
| 2 | + |
| 3 | +import java.io.Serializable; |
| 4 | +import java.util.Collection; |
| 5 | +import javax.persistence.Basic; |
| 6 | +import javax.persistence.Column; |
| 7 | +import javax.persistence.Entity; |
| 8 | +import javax.persistence.Id; |
| 9 | +import javax.persistence.NamedQueries; |
| 10 | +import javax.persistence.NamedQuery; |
| 11 | +import javax.persistence.OneToMany; |
| 12 | +import javax.persistence.Table; |
| 13 | + |
| 14 | +@Entity |
| 15 | +@Table(name = "Barco") |
| 16 | +@NamedQueries({ |
| 17 | + @NamedQuery(name = "Barco.findAll", query = "SELECT b FROM Barco b"), |
| 18 | + @NamedQuery(name = "Barco.findByMatricula", query = "SELECT b FROM Barco b WHERE b.matricula = :matricula"), |
| 19 | + @NamedQuery(name = "Barco.findByNombre", query = "SELECT b FROM Barco b WHERE b.nombre = :nombre"), |
| 20 | + @NamedQuery(name = "Barco.findByNacionalidad", query = "SELECT b FROM Barco b WHERE b.nacionalidad = :nacionalidad"), |
| 21 | + @NamedQuery(name = "Barco.findByCapacidadCarga", query = "SELECT b FROM Barco b WHERE b.capacidadCarga = :capacidadCarga"), |
| 22 | + @NamedQuery(name = "Barco.findByVela", query = "SELECT b FROM Barco b WHERE b.vela = :vela")}) |
| 23 | +public class Barco implements Serializable { |
| 24 | + |
| 25 | + private static final long serialVersionUID = 1L; |
| 26 | + @Id |
| 27 | + @Basic(optional = false) |
| 28 | + @Column(name = "matricula") |
| 29 | + private Integer matricula; |
| 30 | + @Column(name = "nombre") |
| 31 | + private String nombre; |
| 32 | + @Column(name = "nacionalidad") |
| 33 | + private String nacionalidad; |
| 34 | + @Column(name = "capacidadCarga") |
| 35 | + private Integer capacidadCarga; |
| 36 | + @Column(name = "vela") |
| 37 | + private Boolean vela; |
| 38 | + @OneToMany(mappedBy = "barco") |
| 39 | + private Collection<Marinero> marineroCollection; |
| 40 | + |
| 41 | + public Barco() { |
| 42 | + } |
| 43 | + |
| 44 | + public Barco(Integer matricula) { |
| 45 | + this.matricula = matricula; |
| 46 | + } |
| 47 | + |
| 48 | + public Integer getMatricula() { |
| 49 | + return matricula; |
| 50 | + } |
| 51 | + |
| 52 | + public void setMatricula(Integer matricula) { |
| 53 | + this.matricula = matricula; |
| 54 | + } |
| 55 | + |
| 56 | + public String getNombre() { |
| 57 | + return nombre; |
| 58 | + } |
| 59 | + |
| 60 | + public void setNombre(String nombre) { |
| 61 | + this.nombre = nombre; |
| 62 | + } |
| 63 | + |
| 64 | + public String getNacionalidad() { |
| 65 | + return nacionalidad; |
| 66 | + } |
| 67 | + |
| 68 | + public void setNacionalidad(String nacionalidad) { |
| 69 | + this.nacionalidad = nacionalidad; |
| 70 | + } |
| 71 | + |
| 72 | + public Integer getCapacidadCarga() { |
| 73 | + return capacidadCarga; |
| 74 | + } |
| 75 | + |
| 76 | + public void setCapacidadCarga(Integer capacidadCarga) { |
| 77 | + this.capacidadCarga = capacidadCarga; |
| 78 | + } |
| 79 | + |
| 80 | + public Boolean getVela() { |
| 81 | + return vela; |
| 82 | + } |
| 83 | + |
| 84 | + public void setVela(Boolean vela) { |
| 85 | + this.vela = vela; |
| 86 | + } |
| 87 | + |
| 88 | + public Collection<Marinero> getMarineroCollection() { |
| 89 | + return marineroCollection; |
| 90 | + } |
| 91 | + |
| 92 | + public void setMarineroCollection(Collection<Marinero> marineroCollection) { |
| 93 | + this.marineroCollection = marineroCollection; |
| 94 | + } |
| 95 | + |
| 96 | + @Override |
| 97 | + public int hashCode() { |
| 98 | + int hash = 0; |
| 99 | + hash += (matricula != null ? matricula.hashCode() : 0); |
| 100 | + return hash; |
| 101 | + } |
| 102 | + |
| 103 | + @Override |
| 104 | + public boolean equals(Object object) { |
| 105 | + // TODO: Warning - this method won't work in the case the id fields are not set |
| 106 | + if (!(object instanceof Barco)) { |
| 107 | + return false; |
| 108 | + } |
| 109 | + Barco other = (Barco) object; |
| 110 | + if ((this.matricula == null && other.matricula != null) || (this.matricula != null && !this.matricula.equals(other.matricula))) { |
| 111 | + return false; |
| 112 | + } |
| 113 | + return true; |
| 114 | + } |
| 115 | + |
| 116 | + @Override |
| 117 | + public String toString() { |
| 118 | + return "codigo.Barco[ matricula=" + matricula + " ]"; |
| 119 | + } |
| 120 | +} |
0 commit comments