List of usage examples for org.hibernate Query setDate
@Deprecated @SuppressWarnings("unchecked") default Query<R> setDate(String name, Date val)
From source file:ru.codemine.ccms.dao.SalesDAOImpl.java
License:Open Source License
@Override public Integer getCqcountValueByPeriod(Shop shop, LocalDate startDate, LocalDate endDate) { Query query = getSession().createQuery("SELECT SUM(Sm.chequeCountTotal) " + "FROM SalesMeta Sm " + "WHERE Sm.shop.id = :shopid " + "AND Sm.startDate >= :startdate " + "AND Sm.endDate <= :enddate"); query.setInteger("shopid", shop.getId()); query.setDate("startdate", startDate.toDate()); query.setDate("enddate", endDate.toDate()); Long result = (Long) query.uniqueResult(); return result == null ? 0 : result.intValue(); }
From source file:ru.codemine.ccms.dao.SalesDAOImpl.java
License:Open Source License
@Override public Double getValueByPeriod(Shop shop, LocalDate startDate, LocalDate endDate) { Query query = getSession().createQuery("SELECT SUM(Sm.valueTotal) " + "FROM SalesMeta Sm " + "WHERE Sm.shop.id = :shopid " + "AND Sm.startDate >= :startdate " + "AND Sm.endDate <= :enddate"); query.setInteger("shopid", shop.getId()); query.setDate("startdate", startDate.toDate()); query.setDate("enddate", endDate.toDate()); Double result = (Double) query.uniqueResult(); return result == null ? 0.0 : result; }
From source file:ru.codemine.ccms.dao.SalesDAOImpl.java
License:Open Source License
@Override public Double getCashbackValueByPeriod(Shop shop, LocalDate startDate, LocalDate endDate) { Query query = getSession().createQuery("SELECT SUM(Sm.cashbackTotal) " + "FROM SalesMeta Sm " + "WHERE Sm.shop.id = :shopid " + "AND Sm.startDate >= :startdate " + "AND Sm.endDate <= :enddate"); query.setInteger("shopid", shop.getId()); query.setDate("startdate", startDate.toDate()); query.setDate("enddate", endDate.toDate()); Double result = (Double) query.uniqueResult(); return result == null ? 0.0 : result; }
From source file:ru.codemine.ccms.dao.SalesDAOImpl.java
License:Open Source License
@Override public Double getSalesValueByPeriod(Shop shop, LocalDate startDate, LocalDate endDate) { Query query = getSession().createQuery("SELECT SUM(Sm.salesTotal) " + "FROM SalesMeta Sm " + "WHERE Sm.shop.id = :shopid " + "AND Sm.startDate >= :startdate " + "AND Sm.endDate <= :enddate"); query.setInteger("shopid", shop.getId()); query.setDate("startdate", startDate.toDate()); query.setDate("enddate", endDate.toDate()); Double result = (Double) query.uniqueResult(); return result == null ? 0.0 : result; }
From source file:ru.codemine.ccms.dao.SalesDAOImpl.java
License:Open Source License
@Override public Double getPlan(Shop shop, LocalDate startDate, LocalDate endDate) { Query query = getSession().createQuery("SELECT SUM(Sm.plan) " + "FROM SalesMeta Sm " + "WHERE Sm.shop.id = :shopid " + "AND Sm.startDate >= :startdate " + "AND Sm.endDate <= :enddate"); query.setInteger("shopid", shop.getId()); query.setDate("startdate", startDate.toDate()); query.setDate("enddate", endDate.toDate()); Double result = (Double) query.uniqueResult(); return result == null ? 0.0 : result; }
From source file:ru.codemine.ccms.dao.SalesDAOImpl.java
License:Open Source License
@Override public Set<ExpenceType> getExpenceTypesByPeriod(Shop shop, LocalDate startDate, LocalDate endDate) { Query query = getSession().createQuery("SELECT INDEX(Sm.expences) " + "FROM SalesMeta Sm " + "WHERE Sm.shop.id = :shopid " + "AND Sm.startDate >= :startdate " + "AND Sm.endDate <= :enddate"); query.setInteger("shopid", shop.getId()); query.setDate("startdate", startDate.toDate()); query.setDate("enddate", endDate.toDate()); Set<ExpenceType> etSet = new TreeSet<>(query.list()); return etSet; }
From source file:ru.codemine.ccms.dao.SalesDAOImpl.java
License:Open Source License
@Override public Double getTotalExpenceValueForPeriod(Shop shop, LocalDate startDate, LocalDate endDate, ExpenceType type) {//from ww w . j av a 2 s. co m Query query = getSession().createQuery( "FROM SalesMeta Sm " + "WHERE Sm.shop.id = :shopid " + "AND Sm.startDate >= :startdate " + "AND Sm.endDate <= :enddate " + "AND :expenceType IN INDICES(Sm.expences)"); query.setInteger("shopid", shop.getId()); query.setDate("startdate", startDate.toDate()); query.setDate("enddate", endDate.toDate()); query.setParameter("expenceType", type); List<SalesMeta> smList = query.list(); Double result = 0.0; for (SalesMeta sm : smList) { result += sm.getExpences().get(type); } return result; }
From source file:ru.codemine.ccms.dao.SalesDAOImpl.java
License:Open Source License
@Override public Double getTotalExpenceValueForPeriod(Shop shop, LocalDate startDate, LocalDate endDate) { Query query = getSession() .createQuery("SELECT SUM(Sm.expencesTotal) " + "FROM SalesMeta Sm " + "WHERE Sm.shop.id = :shopid " + "AND Sm.startDate >= :startdate " + "AND Sm.endDate <= :enddate "); query.setInteger("shopid", shop.getId()); query.setDate("startdate", startDate.toDate()); query.setDate("enddate", endDate.toDate()); Double result = (Double) query.uniqueResult(); return result == null ? 0.0 : result; }
From source file:ru.codemine.ccms.dao.TaskDAOImpl.java
License:Open Source License
@Override public Integer getClosedTasksByPerformerCount(Employee performer, LocalDate startDate, LocalDate endDate) { Query query = getSession().createQuery( "SELECT COUNT(*) FROM Task t WHERE :performer IN ELEMENTS(t.performers) AND t.closeTime >= :startDate AND t.closeTime <= :endDate"); query.setParameter("performer", performer); query.setDate("startDate", startDate.toDate()); query.setDate("endDate", endDate.toDate()); Long count = (Long) query.uniqueResult(); return count == null ? 0 : count.intValue(); }
From source file:ru.codemine.ccms.dao.TaskDAOImpl.java
License:Open Source License
@Override public Integer getOverdueTasksByPerformerCount(Employee performer, LocalDate startDate, LocalDate endDate) { Query query = getSession().createQuery( "SELECT COUNT(*) FROM Task t WHERE :performer IN ELEMENTS(t.performers) AND t.closeTime >= :startDate AND t.closeTime <= :endDate AND t.deadline < t.closeTime"); query.setParameter("performer", performer); query.setDate("startDate", startDate.toDate()); query.setDate("endDate", endDate.toDate()); Long count = (Long) query.uniqueResult(); return count == null ? 0 : count.intValue(); }