package jpa; import java.io.Serializable; import java.time.LocalTime; import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.EnumType; import javax.persistence.Enumerated; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; import common.MedicalTestType; /** * Los nombres de los decortadores relacionados con la BBDD pueden estar en * camelCase, snakeCase o como se quiera, puesto que en persistence.xml se tiene * dicho que se convierta a minúsculas. * * Lo uso en minúsculas para mejorar la trazabilidad de los campos. * * @author Roberto Orden Erena * */ @Entity @Table(name = "myhealth.medicaltest") public class MedicalTestJPA implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; private Date date; private LocalTime time; private String observations; private String highresimage; @Enumerated(EnumType.STRING) @Column(name = "type") // Con esto podríamos cambiar los nombres de las propiedades de la clase y // mantener la relación con la BBDD a través de JPA private MedicalTestType type; @ManyToOne @JoinColumn(name = "patientid") private PatientJPA patient; @ManyToOne @JoinColumn(name = "specialistdoctorid") private SpecialistDoctorJPA specialistDoctor; public MedicalTestJPA() { super(); } public MedicalTestJPA(Date date, LocalTime time, String observations, String highresimage, MedicalTestType type, PatientJPA patient, SpecialistDoctorJPA specialistDoctor) { this.date = date; this.time = time; this.observations = observations; this.highresimage = highresimage; this.type = type; this.patient = patient; this.specialistDoctor = specialistDoctor; } public int getId() { return id; } public void setId(int id) { this.id = id; } public Date getDate() { return date; } public void setDate(Date date) { this.date = date; } public LocalTime getTime() { return time; } public void setTime(LocalTime time) { this.time = time; } public String getObservations() { return observations; } public void setObservations(String observations) { this.observations = observations; } public String getHighresimage() { return highresimage; } public void setHighresimage(String highresimage) { this.highresimage = highresimage; } public MedicalTestType getType() { return type; } public void setType(MedicalTestType type) { this.type = type; } public PatientJPA getPatient() { return patient; } public void setPatient(PatientJPA patient) { this.patient = patient; } public SpecialistDoctorJPA getSpecialistDoctor() { return specialistDoctor; } public void setSpecialistDoctor(SpecialistDoctorJPA specialistDoctor) { this.specialistDoctor = specialistDoctor; } }