Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package entities;
- import java.io.Serializable;
- import java.util.List;
- import javax.persistence.CascadeType;
- import javax.persistence.Column;
- import javax.persistence.EmbeddedId;
- import javax.persistence.Entity;
- import javax.persistence.JoinColumn;
- import javax.persistence.ManyToOne;
- import javax.persistence.NamedQueries;
- import javax.persistence.NamedQuery;
- import javax.persistence.OneToMany;
- import javax.persistence.Table;
- import javax.validation.constraints.Size;
- import javax.xml.bind.annotation.XmlRootElement;
- import javax.xml.bind.annotation.XmlTransient;
- /**
- *
- * @author Fede-Frost
- */
- @Entity
- @Table(name = "medico")
- @XmlRootElement
- @NamedQueries({
- @NamedQuery(name = "Medico.findAll", query = "SELECT m FROM Medico m")
- , @NamedQuery(name = "Medico.findByCi", query = "SELECT m FROM Medico m WHERE m.medicoPK.ci = :ci")
- , @NamedQuery(name = "Medico.findByNombre", query = "SELECT m FROM Medico m WHERE m.nombre = :nombre")
- , @NamedQuery(name = "Medico.findByApellido", query = "SELECT m FROM Medico m WHERE m.apellido = :apellido")
- , @NamedQuery(name = "Medico.findByTelefono", query = "SELECT m FROM Medico m WHERE m.telefono = :telefono")
- , @NamedQuery(name = "Medico.findByDireccion", query = "SELECT m FROM Medico m WHERE m.direccion = :direccion")
- , @NamedQuery(name = "Medico.findByEspecId", query = "SELECT m FROM Medico m WHERE m.medicoPK.especId = :especId")})
- public class Medico implements Serializable {
- @OneToMany(cascade = CascadeType.ALL, mappedBy = "medico")
- private List<Detalleconsulta> detalleconsultaList;
- private static final long serialVersionUID = 1L;
- @EmbeddedId
- protected MedicoPK medicoPK;
- @Size(max = 45)
- @Column(name = "nombre")
- private String nombre;
- @Size(max = 45)
- @Column(name = "apellido")
- private String apellido;
- @Size(max = 45)
- @Column(name = "telefono")
- private String telefono;
- @Size(max = 45)
- @Column(name = "direccion")
- private String direccion;
- @JoinColumn(name = "espec_id", referencedColumnName = "id", insertable = false, updatable = false)
- @ManyToOne(optional = false)
- private Especialidad especialidad;
- public Medico() {
- }
- public Medico(MedicoPK medicoPK) {
- this.medicoPK = medicoPK;
- }
- public Medico(int ci, int especId) {
- this.medicoPK = new MedicoPK(ci, especId);
- }
- public MedicoPK getMedicoPK() {
- return medicoPK;
- }
- public void setMedicoPK(MedicoPK medicoPK) {
- this.medicoPK = medicoPK;
- }
- public String getNombre() {
- return nombre;
- }
- public void setNombre(String nombre) {
- this.nombre = nombre;
- }
- public String getApellido() {
- return apellido;
- }
- public void setApellido(String apellido) {
- this.apellido = apellido;
- }
- public String getTelefono() {
- return telefono;
- }
- public void setTelefono(String telefono) {
- this.telefono = telefono;
- }
- public String getDireccion() {
- return direccion;
- }
- public void setDireccion(String direccion) {
- this.direccion = direccion;
- }
- public Especialidad getEspecialidad() {
- return especialidad;
- }
- public void setEspecialidad(Especialidad especialidad) {
- this.especialidad = especialidad;
- }
- @Override
- public int hashCode() {
- int hash = 0;
- hash += (medicoPK != null ? medicoPK.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 Medico)) {
- return false;
- }
- Medico other = (Medico) object;
- if ((this.medicoPK == null && other.medicoPK != null) || (this.medicoPK != null && !this.medicoPK.equals(other.medicoPK))) {
- return false;
- }
- return true;
- }
- @Override
- public String toString() {
- return "MyHospital.Medico[ medicoPK=" + medicoPK + " ]";
- }
- @XmlTransient
- public List<Detalleconsulta> getDetalleconsultaList() {
- return detalleconsultaList;
- }
- public void setDetalleconsultaList(List<Detalleconsulta> detalleconsultaList) {
- this.detalleconsultaList = detalleconsultaList;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement