1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
|
Consultation consultationRecherche = new Consultation();
ConsultationId id = new ConsultationId();
id.setDate(new SimpleDateFormat("dd-MM-yy hh:mm:ss").parse("01-03-1985 13:20:00"));
System.out.println(id.getDate()+"-----------------------------------------------------");
id.setPatient_id(11);
ServicesCrudGeneriqueJPA<Consultation, ConsultationId> scConsultation = new ServicesCrudGeneriqueJPA<Consultation, ConsultationId>();
Consultation consultationRech = scConsultation.findById(consultationRecherche, id);
System.out.println(consultationRech);
Consultation consultationTest = AccesBDD.getInstance().createEntityManager().find(Consultation.class, id);
package entites;
import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import entites.clesCompose.ConsultationId;
@SuppressWarnings("serial")
@Entity
@Table(name="consultation")
public class Consultation implements Serializable{
@EmbeddedId
private ConsultationId idCompose = new ConsultationId();
@Column(name="date", nullable = false, insertable=false, updatable=false)
@Temporal(TemporalType.TIMESTAMP)
private Date date;
@Column(name="remarque", nullable = true)
private String remarque;
@ManyToOne
@JoinColumn(name = "patient_id", nullable = false, insertable=false, updatable=false)
private Patient patientAppartientConsultation;
@OneToOne(cascade = CascadeType.ALL, fetch=FetchType.LAZY)
@JoinColumn(name = "facture_id", unique = true, nullable = true)
private Facture factureConsultation;
@ManyToOne
@JoinColumn(name = "therapeute_id", nullable = false, insertable=false, updatable=false)
private Therapeute therapeuteExecuteConsultation;
public Consultation(){
}
public Consultation(Date pDate, String pRemarque){
setRemarque(pRemarque);
setDate(pDate);
}
public ConsultationId getIdCompose() {
return idCompose;
}
public void setIdCompose(ConsultationId idCompose) {
this.idCompose = idCompose;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
this.idCompose.setDate(date);
}
public Patient getPatientAppartientConsultation() {
return patientAppartientConsultation;
}
public void setPatientAppartientConsultation(Patient patientAppartientConsultation) {
this.patientAppartientConsultation = patientAppartientConsultation;
this.idCompose.setPatient_id(patientAppartientConsultation.getId());
}
public String getRemarque() {
return remarque;
}
public void setRemarque(String remarque) {
this.remarque = remarque;
}
public Facture getFactureConsultation() {
return factureConsultation;
}
public void setFactureConsultation(Facture factureConsultation) {
this.factureConsultation = factureConsultation;
}
public Therapeute getTherapeuteExecuteConsultation() {
return therapeuteExecuteConsultation;
}
public void setTherapeuteExecuteConsultation(
Therapeute therapeuteExecuteConsultation) {
this.therapeuteExecuteConsultation = therapeuteExecuteConsultation;
}
}
package entites.clesCompose;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.JoinColumn;
import entites.Patient;
@Embeddable
public class ConsultationId implements Serializable{
@Column(name = "date")
private Date date;
@Column(name = "patient_id")
private Integer patient_id;
public ConsultationId(){
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public Integer getPatient_id() {
return patient_id;
}
public void setPatient_id(Integer patient_id) {
this.patient_id = patient_id;
}
} |
Partager