Example usage for org.hibernate Query setDate

List of usage examples for org.hibernate Query setDate

Introduction

In this page you can find the example usage for org.hibernate Query setDate.

Prototype

@Deprecated
@SuppressWarnings("unchecked")
default Query<R> setDate(String name, Date val) 

Source Link

Document

Bind the val (time is truncated) of a given Date object to a named query parameter.

Usage

From source file:ru.codemine.ccms.dao.ActionEventDAOImpl.java

License:Open Source License

@Override
public List<ActionEvent> getCurrentFuture() {
    Query query = getSession().createQuery("FROM ActionEvent a " + "WHERE a.endDate >= :now");
    query.setDate("now", LocalDate.now().toDate());

    return query.list();
}

From source file:ru.codemine.ccms.dao.CounterDAOImpl.java

License:Open Source License

@Override
public Counter getByShopAndDate(Shop shop, DateTime date) {
    Session session = sessionFactory.getCurrentSession();
    Query q = session.createQuery("FROM Counter C WHERE C.shop.id = " + shop.getId() + " AND C.date = :date");

    q.setDate("date", date.toDate());

    Counter counter = (Counter) q.uniqueResult();

    return counter;
}

From source file:ru.codemine.ccms.dao.CounterDAOImpl.java

License:Open Source License

@Override
public Integer getSumIn(DateTime date) {
    Session session = sessionFactory.getCurrentSession();
    Integer result = 0;// w  w  w .j a va2 s.co  m
    Query q = session.createQuery("FROM Counter C WHERE C.date = :date");

    q.setDate("date", date.toDate());

    List<Counter> counterList = q.list();
    for (Counter c : counterList) {
        result += c.getIn();
    }

    return result;
}

From source file:ru.codemine.ccms.dao.CounterDAOImpl.java

License:Open Source License

@Override
public Integer getSumOut(DateTime date) {
    Session session = sessionFactory.getCurrentSession();
    Integer result = 0;//from   w  w w .  j av a 2  s  .co  m
    Query q = session.createQuery("FROM Counter C WHERE C.date = :date");

    q.setDate("date", date.toDate());

    List<Counter> counterList = q.list();
    for (Counter c : counterList) {
        result += c.getOut();
    }

    return result;
}

From source file:ru.codemine.ccms.dao.CounterDAOImpl.java

License:Open Source License

@Override
public Integer getInValueByPeriod(Shop shop, LocalDate dateStart, LocalDate dateEnd) {
    Session session = sessionFactory.getCurrentSession();
    Query query = session.createQuery(
            "SELECT SUM(c.in) FROM Counter c WHERE c.shop.id = :id AND c.date >= :dateStart AND c.date <= :dateEnd");
    query.setInteger("id", shop.getId());
    query.setDate("dateStart", dateStart.toDate());
    query.setDate("dateEnd", dateEnd.toDate());

    Long result = (Long) query.uniqueResult();

    return result == null ? 0 : result.intValue();
}

From source file:ru.codemine.ccms.dao.CounterDAOImpl.java

License:Open Source License

@Override
public Integer getOutValueByPeriod(Shop shop, LocalDate dateStart, LocalDate dateEnd) {
    Session session = sessionFactory.getCurrentSession();
    Query query = session.createQuery(
            "SELECT SUM(c.out) FROM Counter c WHERE c.shop.id = :id AND c.date >= :dateStart AND c.date <= :dateEnd");
    query.setInteger("id", shop.getId());
    query.setDate("dateStart", dateStart.toDate());
    query.setDate("dateEnd", dateEnd.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 boolean updatePlanAll(Double plan, LocalDate startDate, LocalDate endDate) {
    if (plan == null || startDate == null || endDate == null || startDate.isAfter(endDate))
        return false;

    Query updateQuery = getSession().createQuery("UPDATE SalesMeta Sm " + "SET Sm.plan = :plan "
            + "WHERE Sm.startDate = :startdate " + "AND Sm.endDate = :enddate");
    updateQuery.setDate("startdate", startDate.toDate());
    updateQuery.setDate("enddate", endDate.toDate());
    updateQuery.setDouble("plan", plan);

    return updateQuery.executeUpdate() > 0;
}

From source file:ru.codemine.ccms.dao.SalesDAOImpl.java

License:Open Source License

@Override
public SalesMeta getByShopAndDate(Shop shop, LocalDate startDate, LocalDate endDate) {
    Query query = getSession().createQuery("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());

    return (SalesMeta) query.uniqueResult();
}

From source file:ru.codemine.ccms.dao.SalesDAOImpl.java

License:Open Source License

@Override
public List<SalesMeta> getByPeriod(Shop shop, LocalDate startDate, LocalDate endDate) {
    Query query = getSession().createQuery("FROM SalesMeta Sm " + "WHERE Sm.shop.id = :shopid "
            + "AND Sm.startDate >= :startdate " + "AND Sm.endDate <= :enddate " + "ORDER BY Sm.startDate ASC");
    query.setInteger("shopid", shop.getId());
    query.setDate("startdate", startDate.toDate());
    query.setDate("enddate", endDate.toDate());

    return query.list();
}

From source file:ru.codemine.ccms.dao.SalesDAOImpl.java

License:Open Source License

@Override
public Integer getPassabilityValueByPeriod(Shop shop, LocalDate startDate, LocalDate endDate) {
    Query query = getSession().createQuery("SELECT SUM(Sm.passabilityTotal) " + "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();
}