Advertisement
Guest User

medico.java

a guest
Jul 17th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.58 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package entities;
  7.  
  8. import java.io.Serializable;
  9. import java.util.List;
  10. import javax.persistence.CascadeType;
  11. import javax.persistence.Column;
  12. import javax.persistence.EmbeddedId;
  13. import javax.persistence.Entity;
  14. import javax.persistence.JoinColumn;
  15. import javax.persistence.ManyToOne;
  16. import javax.persistence.NamedQueries;
  17. import javax.persistence.NamedQuery;
  18. import javax.persistence.OneToMany;
  19. import javax.persistence.Table;
  20. import javax.validation.constraints.Size;
  21. import javax.xml.bind.annotation.XmlRootElement;
  22. import javax.xml.bind.annotation.XmlTransient;
  23.  
  24. /**
  25. *
  26. * @author Fede-Frost
  27. */
  28. @Entity
  29. @Table(name = "medico")
  30. @XmlRootElement
  31. @NamedQueries({
  32. @NamedQuery(name = "Medico.findAll", query = "SELECT m FROM Medico m")
  33. , @NamedQuery(name = "Medico.findByCi", query = "SELECT m FROM Medico m WHERE m.medicoPK.ci = :ci")
  34. , @NamedQuery(name = "Medico.findByNombre", query = "SELECT m FROM Medico m WHERE m.nombre = :nombre")
  35. , @NamedQuery(name = "Medico.findByApellido", query = "SELECT m FROM Medico m WHERE m.apellido = :apellido")
  36. , @NamedQuery(name = "Medico.findByTelefono", query = "SELECT m FROM Medico m WHERE m.telefono = :telefono")
  37. , @NamedQuery(name = "Medico.findByDireccion", query = "SELECT m FROM Medico m WHERE m.direccion = :direccion")
  38. , @NamedQuery(name = "Medico.findByEspecId", query = "SELECT m FROM Medico m WHERE m.medicoPK.especId = :especId")})
  39. public class Medico implements Serializable {
  40.  
  41. @OneToMany(cascade = CascadeType.ALL, mappedBy = "medico")
  42. private List<Detalleconsulta> detalleconsultaList;
  43.  
  44. private static final long serialVersionUID = 1L;
  45. @EmbeddedId
  46. protected MedicoPK medicoPK;
  47. @Size(max = 45)
  48. @Column(name = "nombre")
  49. private String nombre;
  50. @Size(max = 45)
  51. @Column(name = "apellido")
  52. private String apellido;
  53. @Size(max = 45)
  54. @Column(name = "telefono")
  55. private String telefono;
  56. @Size(max = 45)
  57. @Column(name = "direccion")
  58. private String direccion;
  59. @JoinColumn(name = "espec_id", referencedColumnName = "id", insertable = false, updatable = false)
  60. @ManyToOne(optional = false)
  61. private Especialidad especialidad;
  62.  
  63. public Medico() {
  64. }
  65.  
  66. public Medico(MedicoPK medicoPK) {
  67. this.medicoPK = medicoPK;
  68. }
  69.  
  70. public Medico(int ci, int especId) {
  71. this.medicoPK = new MedicoPK(ci, especId);
  72. }
  73.  
  74. public MedicoPK getMedicoPK() {
  75. return medicoPK;
  76. }
  77.  
  78. public void setMedicoPK(MedicoPK medicoPK) {
  79. this.medicoPK = medicoPK;
  80. }
  81.  
  82. public String getNombre() {
  83. return nombre;
  84. }
  85.  
  86. public void setNombre(String nombre) {
  87. this.nombre = nombre;
  88. }
  89.  
  90. public String getApellido() {
  91. return apellido;
  92. }
  93.  
  94. public void setApellido(String apellido) {
  95. this.apellido = apellido;
  96. }
  97.  
  98. public String getTelefono() {
  99. return telefono;
  100. }
  101.  
  102. public void setTelefono(String telefono) {
  103. this.telefono = telefono;
  104. }
  105.  
  106. public String getDireccion() {
  107. return direccion;
  108. }
  109.  
  110. public void setDireccion(String direccion) {
  111. this.direccion = direccion;
  112. }
  113.  
  114. public Especialidad getEspecialidad() {
  115. return especialidad;
  116. }
  117.  
  118. public void setEspecialidad(Especialidad especialidad) {
  119. this.especialidad = especialidad;
  120. }
  121.  
  122. @Override
  123. public int hashCode() {
  124. int hash = 0;
  125. hash += (medicoPK != null ? medicoPK.hashCode() : 0);
  126. return hash;
  127. }
  128.  
  129. @Override
  130. public boolean equals(Object object) {
  131. // TODO: Warning - this method won't work in the case the id fields are not set
  132. if (!(object instanceof Medico)) {
  133. return false;
  134. }
  135. Medico other = (Medico) object;
  136. if ((this.medicoPK == null && other.medicoPK != null) || (this.medicoPK != null && !this.medicoPK.equals(other.medicoPK))) {
  137. return false;
  138. }
  139. return true;
  140. }
  141.  
  142. @Override
  143. public String toString() {
  144. return "MyHospital.Medico[ medicoPK=" + medicoPK + " ]";
  145. }
  146.  
  147. @XmlTransient
  148. public List<Detalleconsulta> getDetalleconsultaList() {
  149. return detalleconsultaList;
  150. }
  151.  
  152. public void setDetalleconsultaList(List<Detalleconsulta> detalleconsultaList) {
  153. this.detalleconsultaList = detalleconsultaList;
  154. }
  155.  
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement