我必须从数据表中检索选定患者的最后一次访问问题是查询总是返回公牛,这是负责的代码:
public class PatientDao implements Serializable {
......
public List<String> findWithQuery(String query ,int id) {
Query q= this.getEntityManager().createQuery(query).setParameter("id",id);
return q.getResultList();
}
}
......
}
@ManagedBean
@SessionScoped
@SuppressWarnings("serial")
public class PatientCtrl implements Serializable{
......
private static Patient selectedpatient = new Patient();
private static PatientDao pDao = new PatientDao();
private static String lv ;
......
public void lastVisit()
{
this.setLv( pDao.findWithQuery("select max(v.date) from Visite v where v.patient.id = :id ",selectedpatient.getId()).toString().replaceAll("^\\[", "").replaceAll("\\]$", ""));
}
<h3>Dernière visite</h3>
<p:outputLabel value="#{patientCtrl.lv}" />
它总是空的