List of usage examples for org.hibernate Query setDate
@Deprecated @SuppressWarnings("unchecked") default Query<R> setDate(String name, Date val)
From source file:us.mn.state.health.lims.analysis.daoimpl.AnalysisDAOImpl.java
License:Mozilla Public License
@Override public List<Analysis> getAnalysisByTestDescriptionAndCompletedDateRange(List<String> descriptions, Date lowDate, Date highDate) throws LIMSRuntimeException { if (descriptions.isEmpty()) { return new ArrayList<Analysis>(); }/* w w w .j av a 2 s . c o m*/ String sql = "From Analysis a where a.test.description in (:descriptions) and a.completedDate BETWEEN :lowDate AND :highDate"; try { Query query = HibernateUtil.getSession().createQuery(sql); query.setParameterList("descriptions", descriptions); query.setDate("lowDate", lowDate); query.setDate("highDate", highDate); @SuppressWarnings("unchecked") List<Analysis> list = query.list(); closeSession(); return list; } catch (HibernateException he) { handleException(he, "getAnalysisByTestDescriptionsAndCompletedDateRange"); } return null; }
From source file:us.mn.state.health.lims.dataexchange.aggregatereporting.daoimpl.ReportExternalExportDAOImpl.java
License:Mozilla Public License
@Override public ReportExternalExport getReportByEventDateAndType(ReportExternalExport report) throws LIMSRuntimeException { String sql = "From ReportExternalExport ree where ree.eventDate >= :eventDate and ree.eventDate < :nextDay and ree.typeId = :typeId"; try {//from w w w . j av a 2s . c o m Query query = HibernateUtil.getSession().createQuery(sql); query.setDate("eventDate", report.getEventDate()); query.setDate("nextDay", new Timestamp(report.getEventDate().getTime() + DAY_IN_MILLSEC)); query.setInteger("typeId", Integer.parseInt(report.getTypeId())); ReportExternalExport foundReport = (ReportExternalExport) query.setMaxResults(1).uniqueResult(); closeSession(); return foundReport == null ? report : foundReport; } catch (HibernateException e) { handleException(e, "getReportByEventDateAndType"); } return report; }
From source file:us.mn.state.health.lims.dataexchange.aggregatereporting.daoimpl.ReportExternalImportDAOImpl.java
License:Mozilla Public License
@Override public ReportExternalImport getReportByEventDateSiteType(ReportExternalImport importReport) throws LIMSRuntimeException { String sql = "from ReportExternalImport rei where rei.eventDate = :eventDate and rei.sendingSite = :site and rei.reportType = :type"; try {//from w ww.j ava 2 s .c om Query query = HibernateUtil.getSession().createQuery(sql); query.setDate("eventDate", importReport.getEventDate()); query.setString("site", importReport.getSendingSite()); query.setString("type", importReport.getReportType()); ReportExternalImport rei = (ReportExternalImport) query.uniqueResult(); closeSession(); return rei; } catch (HibernateException e) { handleException(e, "getReportByEventDateSiteType"); } return null; }
From source file:us.mn.state.health.lims.referral.daoimpl.ReferralDAOImpl.java
License:Mozilla Public License
/** * @see us.mn.state.health.lims.referral.dao.ReferralDAO#getAllReferralsByOrganization(java.lang.String, java.sql.Date, java.sql.Date) *//* www. j a va 2 s. c o m*/ @SuppressWarnings("unchecked") @Override public List<Referral> getAllReferralsByOrganization(String organizationId, Date lowDate, Date highDate) { String sql = "FROM Referral r WHERE r.organization.id = :organizationId AND r.requestDate >= :lowDate AND r.requestDate <= :highDate"; try { Query query = HibernateUtil.getSession().createQuery(sql); query.setInteger("organizationId", Integer.parseInt(organizationId)); query.setDate("lowDate", lowDate); query.setDate("highDate", highDate); List<Referral> referralList = query.list(); closeSession(); return referralList; } catch (HibernateException e) { handleException(e, "getAllReferralsByOrganization"); } return new ArrayList<Referral>(); }
From source file:us.mn.state.health.lims.referral.daoimpl.ReferringTestResultDAOImpl.java
License:Mozilla Public License
@Override public List<ReferringTestResult> getResultsInDateRange(Date lowDate, Date highDate) throws LIMSRuntimeException { String sql = "from ReferringTestResult rtr where rtr.lastupdated BETWEEN :lowDate AND :highDate"; try {/* w w w . j a v a2 s. c o m*/ Query query = HibernateUtil.getSession().createQuery(sql); query.setDate("lowDate", lowDate); query.setDate("highDate", highDate); List<ReferringTestResult> list = query.list(); closeSession(); return list; } catch (HibernateException e) { handleException(e, "getResultsInDateRange"); } return null; }
From source file:us.mn.state.health.lims.sampleproject.daoimpl.SampleProjectDAOImpl.java
License:Mozilla Public License
@SuppressWarnings("unchecked") @Override/*from w w w .j av a2s. c o m*/ public List<SampleProject> getByOrganizationProjectAndReceivedOnRange(String organizationId, String projectName, Date lowReceivedDate, Date highReceivedDate) throws LIMSRuntimeException { List<SampleProject> list = null; try { String sql = "FROM SampleProject as sp " + " WHERE sp.project.projectName = :projectName AND sp.sample.id IN (SELECT so.sample.id FROM SampleOrganization as so WHERE so.sample.receivedTimestamp >= :dateLow AND so.sample.receivedTimestamp <= :dateHigh " + " AND so.organization.id = :organizationId ) "; Query query = HibernateUtil.getSession().createQuery(sql); query.setString("projectName", projectName); query.setDate("dateLow", lowReceivedDate); query.setDate("dateHigh", highReceivedDate); query.setInteger("organizationId", Integer.valueOf(organizationId)); list = query.list(); } catch (Exception e) { LogEvent.logError("SampleDAOImpl", "getSamplesByOrganiztionAndReceivedOnRange()", e.toString()); throw new LIMSRuntimeException( "Exception occurred in SampleNumberDAOImpl.getByOrganizationProjectAndReceivedOnRange", e); } return list; }
From source file:us.mn.state.health.lims.sampleqaevent.daoimpl.SampleQaEventDAOImpl.java
License:Mozilla Public License
/** * @see us.mn.state.health.lims.sampleqaevent.dao.SampleQaEventDAO#getSampleQaEventsByUpdatedDate(java.sql.Date, java.sql.Date) *///from ww w . ja v a 2 s .c o m @Override @SuppressWarnings("unchecked") public List<SampleQaEvent> getSampleQaEventsByUpdatedDate(Date lowDate, Date highDate) throws LIMSRuntimeException { List<SampleQaEvent> sampleQaEvents = null; try { String sql = "FROM SampleQaEvent sqe WHERE sqe.lastupdated >= :lowDate AND sqe.lastupdated <= :highDate"; Query query = HibernateUtil.getSession().createQuery(sql); query.setDate("lowDate", lowDate); query.setDate("highDate", highDate); sampleQaEvents = query.list(); closeSession(); } catch (Exception e) { handleException(e, "getSampleQaEventsByDate"); } return sampleQaEvents; }
From source file:utbm.projet.formation.repository.DaoCourse_Session.java
/** * //from w ww. j a va2 s . co m * @param value * @return */ public List<Course_Session> getCoursesWithDetails(Date start_date) { Session session = HibernateUtil.getSessionFactory().openSession(); List<Course_Session> course_Session = new ArrayList<Course_Session>(); try { session.beginTransaction(); String sql = "from Course_Session cs where cs.start_date=:start_date"; Query query = session.createQuery(sql); query.setDate("start_date", start_date); course_Session = query.list(); session.getTransaction().commit(); } catch (HibernateException he) { he.printStackTrace(); if (session.getTransaction() != null) { try { session.getTransaction().rollback(); } catch (HibernateException he2) { he2.printStackTrace(); } } } return course_Session; }