This commit is contained in:
Roberto Orden Erena
2019-12-15 20:53:51 +01:00
parent 91f6bc396b
commit fbe7b34a32
6 changed files with 113 additions and 259 deletions

View File

@@ -3,6 +3,7 @@ package jpa;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
@@ -11,16 +12,19 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import TO.PatientTO;
import TO.SpecialistDoctorTO;
/**
* 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.
*
* @author Marcos García Núñez (mgarcianun@uoc.edu)
* Lo uso en minúsculas para mejorar la trazabilidad de los campos.
*
* @author Roberto Orden Erena <rorden@uoc.edu>
*
*/
@Entity
@Table(name = "MyHealth.MedicalTest")
@Table(name = "myhealth.medicaltest")
public class MedicalTestJPA implements Serializable {
private static final long serialVersionUID = 1L;
@@ -32,22 +36,23 @@ public class MedicalTestJPA implements Serializable {
private long time;
private String observations;
private String highresimage;
@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 int type;
@ManyToOne
@JoinColumn (name="PatientId")
private PatientTO patient;
@JoinColumn (name="patientid")
private PatientJPA patient;
@ManyToOne
@JoinColumn (name="SpecialistDoctorId")
private SpecialistDoctorTO specialistDoctor;
@JoinColumn (name="specialistdoctorid")
private SpecialistDoctorJPA specialistDoctor;
public MedicalTestJPA() {
super();
}
public MedicalTestJPA(int id, Date date, long time, String observations, String highresimage, int type,
PatientTO patient, SpecialistDoctorTO specialistDoctor) {
PatientJPA patient, SpecialistDoctorJPA specialistDoctor) {
this.id = id;
this.date = date;
this.time = time;
@@ -106,19 +111,19 @@ public class MedicalTestJPA implements Serializable {
this.type = type;
}
public PatientTO getPatient() {
public PatientJPA getPatient() {
return patient;
}
public void setPatient(PatientTO patient) {
public void setPatient(PatientJPA patient) {
this.patient = patient;
}
public SpecialistDoctorTO getSpecialistDoctor() {
public SpecialistDoctorJPA getSpecialistDoctor() {
return specialistDoctor;
}
public void setSpecialistDoctor(SpecialistDoctorTO specialistDoctor) {
public void setSpecialistDoctor(SpecialistDoctorJPA specialistDoctor) {
this.specialistDoctor = specialistDoctor;
}