List of usage examples for org.hibernate Query setDate
@Deprecated @SuppressWarnings("unchecked") default Query<R> setDate(String name, Date val)
From source file:org.egov.commons.dao.InstallmentHibDao.java
License:Open Source License
@Override public List<Installment> getInstallmentsByModuleBetweenFromDateAndToDateAndInstallmentType(final Module module, final Date fromDate, final Date toDate, 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", fromDate); qry.setDate("tillDate", toDate); qry.setString("installmentType", installmentType); return qry.list(); }
From source file:org.egov.commons.dao.InstallmentHibDao.java
License:Open Source License
@Override public List<Installment> getInstallmentsByModuleBetweenFromDateAndToDate(final Module module, final Date fromDate, final Date toDate) { final Query qry = getCurrentSession().createQuery( "from Installment I where I.module=:module and I.toDate >=:fromDate and I.fromDate<=:tillDate"); qry.setEntity("module", module); qry.setDate("fromDate", fromDate); qry.setDate("tillDate", toDate); return qry.list(); }
From source file:org.egov.commons.dao.InstallmentHibDao.java
License:Open Source License
@Override public List<Installment> getInstallmentsByModuleAndFromDateAndInstallmentType(final Module module, final Date fromDate, final Date currentDate, final String installmentType) { final Query qry = getCurrentSession().createQuery( "from Installment I where I.module=:module and I.toDate >=:fromDate and I.fromDate<=:tillDate and I.installmentType = :installmentType"); qry.setEntity("module", module); qry.setDate("fromDate", fromDate); qry.setDate("tillDate", currentDate); qry.setString("installmentType", installmentType); return qry.list(); }
From source file:org.egov.commons.dao.InstallmentHibDao.java
License:Open Source License
@Override public List<Installment> fetchInstallments(final Module module, final Date toInstallmentDate, final int noOfInstallmentToFetch) { final Query qry = getCurrentSession().createQuery( "from Installment I where I.module=:module and I.installmentYear<=:installmentYear order by installmentYear desc"); qry.setEntity("module", module); qry.setDate("installmentYear", toInstallmentDate); qry.setMaxResults(noOfInstallmentToFetch); return qry.list(); }
From source file:org.egov.commons.dao.InstallmentHibDao.java
License:Open Source License
@Override public List<Installment> getAllInstallmentsByModuleAndStartDate(final Module module, final Date currDate) { final Query qry = getCurrentSession().createQuery( " select inst from Installment inst,CFinancialYear finYear where inst.module=:module and inst.fromDate >= (select fromDate from Installment " + " where module=:module and ((cast(:currDate as date)) between fromDate and toDate)) and cast(inst.toDate as date) <= cast(finYear.endingDate as date) " + " and now() between finYear.startingDate and finYear.endingDate order by inst.fromDate"); qry.setLong("module", module.getId()); qry.setDate("currDate", currDate); return qry.list(); }
From source file:org.egov.commons.dao.InstallmentHibDao.java
License:Open Source License
@Override public List<Installment> fetchPreviousInstallmentsInDescendingOrderByModuleAndDate(final Module module, final Date installmentDate, final int noOfInstallmentToFetch) { final Query qry = getCurrentSession().createQuery( "from Installment I where I.module=:module and I.toDate< :installmentDate order by fromDate desc"); qry.setEntity("module", module); qry.setDate("installmentDate", installmentDate); qry.setMaxResults(noOfInstallmentToFetch); return qry.list(); }
From source file:org.egov.commons.dao.InstallmentHibDao.java
License:Open Source License
@Override public List<Installment> fetchNextInstallmentsByModuleAndDate(final Module module, final Date date) { final Query qry = getCurrentSession().createQuery( "from Installment I where I.module=:module and I.fromDate>= :installmentDate order by fromDate desc"); qry.setEntity("module", module); qry.setDate("installmentDate", date); return qry.list(); }
From source file:org.egov.commons.service.FinancialYearService.java
License:Open Source License
public CFinancialYear getCurrentFinancialYear() { Date date = new Date(); CFinancialYear cFinancialYear = null; Query query = getSession().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 is not active For Posting."); return cFinancialYear; }
From source file:org.egov.dao.recoveries.EgDeductionDetailsHibernateDAO.java
License:Open Source License
public EgDeductionDetails findEgDeductionDetailsForDeduAmt(final Recovery recovery, final EgPartytype egPartyType, final EgPartytype egPartySubType, final EgwTypeOfWork docType, final Date date) { EgDeductionDetails egDeductionDetails = null; session = getCurrentSession();// w w w . ja v a 2 s .c o m Query qry; final StringBuffer qryStr = new StringBuffer(); qryStr.append("from EgDeductionDetails ed where ed.recovery=:recovery "); if (null != egPartySubType) qryStr.append(" and ed.egpartytype =:egPartySubType "); if (null != docType) qryStr.append(" and ed.workDocType =:docType "); if (null != date) qryStr.append( " and ((ed.datefrom <=:date and ed.dateto>=:date and ed.dateto is not null) or (ed.datefrom<=:date and ed.dateto is null)) "); qry = session.createQuery(qryStr.toString()); if (null != recovery) qry.setEntity("recovery", recovery); if (null != egPartySubType) qry.setEntity("egPartySubType", egPartySubType); if (null != docType) qry.setEntity("docType", docType); if (null != date) qry.setDate("date", date); egDeductionDetails = (EgDeductionDetails) qry.uniqueResult(); return egDeductionDetails; }
From source file:org.egov.egf.commons.EgovCommon.java
License:Open Source License
/** * This method will return sum of bill amount for the given combination of AccountdetailTypeid and AccountdetailKeyid for * which the AccountdetailTypeid amount is on the DEBIT SIDE . * * Important Bills created from Financials module will only be considered * * @param Chartofaccounts - glcode - cannot be null * @param Subledger Type- cannot be null * @param accountdetailKey - detail key ID - cannot be null * @param ToDate - the upper limit of the voucherdates of the associated vouchers - current date is taken if null is passed * * @return BigDecimal value, if there are no voucher created for the zero is returned * * @throws ApplicationRuntimeException glcode, subledger or accountdetailkey or ToDate parameter is null * ApplicationRuntimeException if chartofaccounts or accountdetailkey doesnot exist in system * @author shamili.gupta//from ww w . j a va2s . c o m */ public BigDecimal getSumOfBillAmount(final String glcode, final String subledgerType, final Long accountdetailkeyId, final Date toBillDate) throws ApplicationRuntimeException, ValidationException { final StringBuffer query = new StringBuffer(500); final Session session = persistenceService.getSession(); if (LOGGER.isDebugEnabled()) LOGGER.debug(" Inside getSumOfBillCreated -Glcode :" + glcode + " subledgerType: " + subledgerType + " accountdetailkeyId: " + accountdetailkeyId + " toBillDate: " + toBillDate); if (glcode == null) throw new ApplicationRuntimeException("Glcode cannot be null"); if (subledgerType == null) throw new ApplicationRuntimeException("SubledgerType cannot be null"); if (accountdetailkeyId == null) throw new ApplicationRuntimeException("AccountdetailkeyId cannot be null"); if (toBillDate == null) throw new ApplicationRuntimeException("To Date cannot be null"); final Query qry = session .createQuery("from CChartOfAccounts c where c.glcode=:glcode and c.classification=4 "); qry.setString("glcode", glcode); final List<Object> coaRes = qry.list(); if (null == coaRes || coaRes.size() == 0) throw new ValidationException( Arrays.asList(new ValidationError(glcode, "Account code " + glcode + " does not exists "))); final Query actQry = session.createQuery( "from Accountdetailkey adk where adk.accountdetailtype.name=:subledgerType and adk.detailkey=:detailkey"); actQry.setString("subledgerType", subledgerType); actQry.setInteger("detailkey", accountdetailkeyId.intValue()); final List<Object> actRes = actQry.list(); if (null == actRes || actRes.size() == 0) throw new ValidationException(Arrays .asList(new ValidationError("Accountdetailkey", "The accountdetailkey " + accountdetailkeyId + " for the accountdetailType : " + subledgerType + " does not exist "))); query.append( "select sum(epayee.debitAmount) FROM EgBillPayeedetails epayee, EgwStatus estatus, CChartOfAccounts coa,Accountdetailtype act ") .append(" WHERE act.name=:subledger and act.id=epayee.accountDetailTypeId and epayee.accountDetailKeyId=:accountdetailkey and ") .append(" coa.glcode=:glcode") .append(" and epayee.egBilldetailsId.egBillregister.status=estatus and epayee.egBilldetailsId.egBillregister.egBillregistermis.voucherHeader.status=0 ") .append(" and coa.id=epayee.egBilldetailsId.glcodeid and epayee.egBilldetailsId.egBillregister.billdate<=:billdate ") .append(" and epayee.egBilldetailsId.egBillregister.egBillregistermis.voucherHeader.moduleId is NULL ") .append(" and epayee.egBilldetailsId.egBillregister.state is null and estatus.code ='APPROVED' ") .append(" and epayee.egBilldetailsId.egBillregister.expendituretype='Works' group by epayee.accountDetailKeyId"); final Query amountQry = session.createQuery(query.toString()); amountQry.setString("subledger", subledgerType); amountQry.setInteger("accountdetailkey", accountdetailkeyId.intValue()); amountQry.setString("glcode", glcode); amountQry.setDate("billdate", toBillDate); // if(LOGGER.isInfoEnabled()) LOGGER.info("----------------:"+amountQry.list()); BigDecimal result = BigDecimal.ZERO; if (!amountQry.list().isEmpty()) result = (BigDecimal) amountQry.list().get(0); else result = BigDecimal.ZERO; // amountQry.list().isEmpty() if (LOGGER.isDebugEnabled()) LOGGER.debug(" Total bill amount generated for the " + subledgerType + "is :" + result); return result; }