List of usage examples for org.hibernate Query setInteger
@Deprecated @SuppressWarnings("unchecked") default Query<R> setInteger(String name, int val)
From source file:com.ocare.obook.dao.impl.ReservationDaoImpl.java
@Override public List<Reservation> getReservationsForPatient(final Integer patientId) { return getHibernateTemplate().execute(new HibernateCallback<List<Reservation>>() { @Override/*from w w w. j a va 2s . com*/ public List<Reservation> doInHibernate(Session sn) throws HibernateException { Query query = sn.createQuery( "select r from Reservation r inner join r.patient p where p.id=:patientId order by r.reservationDate desc"); query.setInteger("patientId", patientId); return (List<Reservation>) query.list(); } }); }
From source file:com.ocare.obook.dao.impl.ReservationDaoImpl.java
@Override public List<Reservation> getReservationsForPatientByDates(final Integer patientId, final Date fromDate, final Date toDate) { return getHibernateTemplate().execute(new HibernateCallback<List<Reservation>>() { @Override/*from w w w . j av a 2s. c om*/ public List<Reservation> doInHibernate(Session sn) throws HibernateException { Query query = sn.createQuery( "select r from Reservation r inner join r.patient p where p.id=:patientId and r.reservationDate BETWEEN :fromDate AND :toDate order by r.reservationDate desc"); query.setInteger("patientId", patientId); query.setDate("fromDate", fromDate); query.setDate("toDate", toDate); return (List<Reservation>) query.list(); } }); }
From source file:com.ocare.obook.dao.impl.ReservationDaoImpl.java
@Override public List<ReportReservationStatus> getReservationStatus(final Integer patientId) { return getHibernateTemplate().execute(new HibernateCallback<List<ReportReservationStatus>>() { @Override/* w ww . j a va2 s . c o m*/ public List<ReportReservationStatus> doInHibernate(Session sn) throws HibernateException { Query query = sn.createQuery( "select r.status as statusName , count(r.status) as occuranceNumber from Reservation r inner join r.patient p where p.id=:patientId group by r.status"); query.setInteger("patientId", patientId); List<ReportReservationStatus> reportReservationStatuses = query .setResultTransformer(Transformers.aliasToBean(ReportReservationStatus.class)).list(); // return reportReservationStatus return reportReservationStatuses; } }); }
From source file:com.ocare.obook.dao.impl.ReservationDaoImpl.java
@Override public List<ReportReservationStatus> getReservationStatusByDates(final Integer patientId, final Date fromDate, final Date toDate) { return getHibernateTemplate().execute(new HibernateCallback<List<ReportReservationStatus>>() { @Override//from ww w . j ava 2 s . c om public List<ReportReservationStatus> doInHibernate(Session sn) throws HibernateException { Query query = sn.createQuery( "select r.status as statusName , count(r.status) as occuranceNumber from Reservation r inner join r.patient p where p.id=:patientId and r.reservationDate BETWEEN :fromDate AND :toDate group by r.status"); query.setInteger("patientId", patientId); query.setDate("fromDate", fromDate); query.setDate("toDate", toDate); List<ReportReservationStatus> reportReservationStatuses = query .setResultTransformer(Transformers.aliasToBean(ReportReservationStatus.class)).list(); // return result List return reportReservationStatuses; } }); }
From source file:com.ocare.obook.dao.impl.ReservationDaoImpl.java
@Override public List<Reservation> getDoneReservationsForShift(final Date day, final Integer shift) { return getHibernateTemplate().execute(new HibernateCallback<List<Reservation>>() { @Override//from w w w. j a va 2 s . c o m public List<Reservation> doInHibernate(Session sn) throws HibernateException { Query query = sn.createQuery( "select r from Reservation r inner join r.workingTime wt where r.reservationDate = :day and wt.id= :shift and r.status= :status order by attendenceTimeTo asc"); query.setDate("day", day); query.setString("status", "CONFIRMED"); query.setInteger("shift", shift); return (List<Reservation>) query.list(); } }); }
From source file:com.ocare.oclinic.dao.impl.PatientVisitDaoImpl.java
@Override public PatientVisit getLastVisitForPatient(final Integer patientId) { return getHibernateTemplate().execute(new HibernateCallback<PatientVisit>() { @Override//from w w w. j a v a 2 s. com public PatientVisit doInHibernate(Session sn) throws HibernateException { Query query = sn.createQuery( "select v from PatientVisit v inner join v.patient p where p.id = :patientId order by v.visitDate desc"); query.setInteger("patientId", patientId); query.setMaxResults(1); return (PatientVisit) query.uniqueResult(); } }); }
From source file:com.ocare.oclinic.dao.impl.PatientVisitDaoImpl.java
@SuppressWarnings("unchecked") @Override/* w w w . j ava 2 s . c o m*/ public List<PatientVisit> getNofLastVisit(final Integer patientId, final Integer nOfVisits) { return getHibernateTemplate().execute(new HibernateCallback<List<PatientVisit>>() { @Override public List<PatientVisit> doInHibernate(Session sn) throws HibernateException { Query query = sn.createQuery( "select v from PatientVisit v inner join v.patient p where p.id = :patientId order by v.visitDate desc"); query.setInteger("patientId", patientId); query.setMaxResults(nOfVisits); return (List<PatientVisit>) query.list(); } }); }
From source file:com.openkm.dao.DocumentFilterDAO.java
License:Open Source License
/** * Find by pk/*from w ww . jav a 2s . co m*/ */ public static DocumentFilter findByPk(int dfId) throws DatabaseException { log.debug("findByPk({})", dfId); String qs = "from DocumentFilter df where df.id=:id"; Session session = null; try { session = HibernateUtil.getSessionFactory().openSession(); Query q = session.createQuery(qs); q.setInteger("id", dfId); DocumentFilter ret = (DocumentFilter) q.setMaxResults(1).uniqueResult(); log.debug("findByPk: {}", ret); return ret; } catch (HibernateException e) { throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }
From source file:com.openkm.extension.dao.ContactDAO.java
License:Open Source License
/** * Find by pk//ww w . j a va 2s . co m */ public static Contact findByPk(int id) throws DatabaseException { log.debug("findByPk({})", id); String qs = "from Contact con where con.id=:id"; Session session = null; try { session = HibernateUtil.getSessionFactory().openSession(); Query q = session.createQuery(qs); q.setInteger("id", id); Contact ret = (Contact) q.setMaxResults(1).uniqueResult(); log.debug("findByPk: {}", ret); return ret; } catch (HibernateException e) { throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }
From source file:com.openkm.extension.dao.ProposedSubscriptionDAO.java
License:Open Source License
/** * Mark proposed as seen/*from w w w . ja v a 2 s . c om*/ */ public static void markSeen(int psId) throws DatabaseException { log.debug("markSeen({})", psId); String qs = "update ProposedSubscriptionReceived ps set ps.seenDate=:seenDate where ps.id=:id"; Session session = null; try { session = HibernateUtil.getSessionFactory().openSession(); Query q = session.createQuery(qs); q.setInteger("id", psId); q.setCalendar("seenDate", Calendar.getInstance()); q.executeUpdate(); log.debug("markSeen: void"); } catch (HibernateException e) { throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }