Ejemplo n.º 1
0
 @Override
 public void add(Queue queue) {
   Session session = HibernateUtil.getSessionFactory().openSession();
   Transaction tr = session.beginTransaction();
   session.save(queue);
   tr.commit();
   session.close();
 }
Ejemplo n.º 2
0
  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();
  }
Ejemplo n.º 3
0
  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();
  }
Ejemplo n.º 4
0
  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;
  }
Ejemplo n.º 5
0
 @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;
 }