@Override public void add(Queue queue) { Session session = HibernateUtil.getSessionFactory().openSession(); Transaction tr = session.beginTransaction(); session.save(queue); tr.commit(); session.close(); }
public void add(List<PatientDocument> patientDocuments) { Session session = HibernateUtil.getSessionFactory().openSession(); Transaction tr = session.beginTransaction(); for (PatientDocument patientDocument : patientDocuments) session.save(patientDocument); tr.commit(); session.close(); }
public void deleteByPatient(Patient patient) { Session session = HibernateUtil.getSessionFactory().openSession(); Transaction tr = session.beginTransaction(); Query q = session.createQuery("delete PatientDocument where patient = :patient"); q.setParameter("patient", patient); q.executeUpdate(); tr.commit(); session.close(); }
public List<PatientDocument> listByPatient(Patient patient) { Session session = HibernateUtil.getSessionFactory().openSession(); Transaction tr = session.beginTransaction(); Criteria cr = session.createCriteria(PatientDocument.class); cr.add(eq("patient", patient)); List<PatientDocument> result = (List<PatientDocument>) cr.list(); tr.commit(); session.close(); return result; }
@Override public long countByStatusAndPlace(String status, String place) { Session session = HibernateUtil.getSessionFactory().openSession(); Criteria cr = session.createCriteria(Queue.class); if (status != null) { cr.add(eq("status", status)); } if (place != null) { cr.add(eq("place", place)); } long result = (Long) cr.setProjection(Projections.rowCount()).uniqueResult(); session.close(); return result; }