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:org.egov.commons.dao.FinancialYearHibernateDAO.java

License:Open Source License

/**
 * gives active and not active FY/*  w  w w .  ja v  a2 s .  c  o  m*/
 */
public CFinancialYear getFinYearByDate(Date date) {
    CFinancialYear cFinancialYear = null;
    logger.info("Obtained session");
    Query query = getCurrentSession().createQuery(
            " from CFinancialYear cfinancialyear where cfinancialyear.startingDate <=:sDate and cfinancialyear.endingDate >=:eDate");
    query.setDate("sDate", date);
    query.setDate("eDate", date);
    ArrayList list = (ArrayList) query.list();
    if (list.size() > 0)
        cFinancialYear = (CFinancialYear) list.get(0);
    if (null == cFinancialYear)
        throw new ApplicationRuntimeException("Financial Year Id does not exist.");
    return cFinancialYear;
}

From source file:org.egov.commons.dao.FinancialYearHibernateDAO.java

License:Open Source License

public List<CFinancialYear> getAllPriorFinancialYears(Date date) {
    Query query = getCurrentSession().createQuery(
            " from CFinancialYear cfinancialyear where cfinancialyear.startingDate <:sDate and isActive=true order by finYearRange desc ");
    query.setDate("sDate", date);
    return query.list();
}

From source file:org.egov.commons.dao.FinancialYearHibernateDAO.java

License:Open Source License

/**
 * returns active FY from the given date
 * example: 01-04-2016 is given then it will return 2016-17,2017-18 and so on till current financial year
 *//*from  w  ww  .  j a  v a 2 s . c o m*/

public List<CFinancialYear> getFinancialYearsAfterFromDate(Date date) {
    Query query = getCurrentSession().createQuery(
            " from CFinancialYear cfinancialyear where cfinancialyear.startingDate >=:sDate and isActive=true order by finYearRange desc ");
    query.setDate("sDate", date);
    return query.list();
}

From source file:org.egov.commons.dao.FiscalPeriodHibernateDAO.java

License:Open Source License

/**
* 
*//*from w  ww  . j  a  v a2s .  com*/
public CFiscalPeriod getFiscalPeriodByDate(Date voucherDate) {
    Query query = getCurrentSession()
            .createQuery("from CFiscalPeriod fp where  :voucherDate between fp.startingDate and fp.endingDate");
    query.setDate("voucherDate", voucherDate);
    query.setCacheable(true);
    return (CFiscalPeriod) query.uniqueResult();
}

From source file:org.egov.commons.dao.InstallmentHibDao.java

License:Open Source License

@Override
public List getInsatllmentByModule(final Module module, final Date year) {
    final Query qry = getCurrentSession()
            .createQuery("from Installment I where I.module=:module and I.installmentYear=:year");
    qry.setEntity("module", module);
    qry.setDate("year", year);

    return qry.list();
}

From source file:org.egov.commons.dao.InstallmentHibDao.java

License:Open Source License

@Override
public Installment getInsatllmentByModule(final Module module, final Date year,
        final Integer installmentNumber) {
    final Query qry = getCurrentSession().createQuery(
            "from Installment I where I.module=:module and I.installmentYear=:year and I.installmentNumber =:instNum");
    qry.setEntity("module", module);
    qry.setDate("year", year);
    qry.setInteger("instNum", installmentNumber);

    return (Installment) qry.uniqueResult();
}

From source file:org.egov.commons.dao.InstallmentHibDao.java

License:Open Source License

@Override
public Installment getInsatllmentByModuleForGivenDate(final Module module, final Date installmentDate) {
    final Query qry = getCurrentSession().createQuery(
            "from Installment I where I.module=:module and (I.fromDate <= :fromYear and I.toDate >=:toYear)");
    qry.setEntity("module", module);
    qry.setDate("fromYear", installmentDate);
    qry.setDate("toYear", installmentDate);

    return (Installment) qry.uniqueResult();

}

From source file:org.egov.commons.dao.InstallmentHibDao.java

License:Open Source License

@Override
public List<Installment> getEffectiveInstallmentsforModuleandDate(final Date dateToCompare,
        final int noOfMonths, final Module mod) {
    final Query qry = getCurrentSession().createQuery(
            "from org.egov.commons.Installment inst where  inst.toDate >= :dateToCompare and inst.toDate < :dateToComparemax   and inst.module=:module");
    qry.setDate("dateToCompare", dateToCompare);
    qry.setEntity("module", mod);
    final Date dateToComparemax = DateUtils.add(dateToCompare, Calendar.MONTH, noOfMonths);
    qry.setDate("dateToComparemax", dateToComparemax);

    return qry.list();
}

From source file:org.egov.commons.dao.InstallmentHibDao.java

License:Open Source License

@Override
public Installment getInsatllmentByModuleForGivenDateAndInstallmentType(final Module module,
        final Date installmentDate, final String installmentType) {
    final Query qry = getCurrentSession().createQuery(
            "from Installment I where I.module=:module and (I.fromDate <= :fromYear and I.toDate >=:toYear) and I.installmentType = :installmentType");
    qry.setEntity("module", module);
    qry.setDate("fromYear", installmentDate);
    qry.setDate("toYear", installmentDate);
    qry.setString("installmentType", installmentType);
    return (Installment) qry.uniqueResult();
}

From source file:org.egov.commons.dao.InstallmentHibDao.java

License:Open Source License

@Override
public List<Installment> getInstallmentsByModuleForGivenDateAndInstallmentType(final Module module,
        final Date installmentDate, final String installmentType) {
    final Query qry = getCurrentSession().createQuery(
            "from Installment I where I.module=:module and I.toDate >=:fromDate and I.toDate<=:tillDate and I.installmentType = :installmentType");
    qry.setEntity("module", module);
    qry.setDate("fromDate", installmentDate);
    qry.setDate("tillDate", new Date());
    qry.setString("installmentType", installmentType);
    return qry.list();
}