@Entity
public class doctor {
@Id
private int id;
private String username;
private String password;
private String phone;
private String email;
@OneToMany(targetEntity = patient.class, cascade = CascadeType.ALL, mappedBy = "doctor")
@Cascade(value = org.hibernate.annotations.CascadeType.ALL)
private Collection<patient> patients = new ArrayList<patient>();
}
@Entity
public class patient {
@Id
private int id;
private String name;
private String surname;
private String phone;
private int systolic;
private int diastolic;
@ManyToOne
private doctor doctor;
}
现在我只能通过这个标准检索医生信息:
Criteria query = session.createCriteria(doctor.class);
query.createCriteria("patients", "p");
query.add(Restrictions.eq("p.phone", phone));
List<doctor> doctorList = (ArrayList<doctor>) query.list();
我如何通过给患者电话、他的医生信息和一些患者信息来使用休眠标准进行检索?
类似: phone=3423423424 ,然后 answear 是:
-------------医生信息----------------------------------患者信息(收缩压、舒张压)-----------
1 "Dr dre" sdfssd 243242 drdre@gmail.com 160 170
160 170
患者信息在哪里
如果没有标准,使用 HQL?