Example usage for org.hibernate Query setEntity

List of usage examples for org.hibernate Query setEntity

Introduction

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

Prototype

@Deprecated
@SuppressWarnings("unchecked")
Query<R> setEntity(String name, Object val);

Source Link

Document

Bind an instance of a mapped persistent class to a named query parameter.

Usage

From source file:org.egov.demand.dao.EgBillDetailsHibDao.java

License:Open Source License

@Override
public List<EgBillDetails> getBillDetailsByBill(EgBill egBill) {
    List<EgBillDetails> billDetList = null;
    Query qry2 = getCurrentSession().createQuery("from EgBillDetails billDet where billDet.egBill =:bill");

    if (egBill != null) {
        qry2.setEntity("bill", egBill);
        billDetList = qry2.list();/*from w  w w.  j  a  v a  2  s .c  o m*/
    }
    return billDetList;
}

From source file:org.egov.payment.dao.PaymentheaderHibernateDAO.java

License:Open Source License

public List<Paymentheader> getPaymentheaderByVoucherHeader(final CVoucherHeader voucherHeader) {
    final Query qry = getCurrentSession().createQuery("from Paymentheader where voucherheader =:voucherHeader");
    qry.setEntity("voucherHeader", voucherHeader);
    return qry.list();
}

From source file:org.egov.pims.commons.service.EisCommonsServiceImpl.java

License:Open Source License

public User getUserforPosition(Position pos) {
    User uerImpl = null;//from w  w w . jav a 2  s .  c om

    try {

        String mainStr = "";
        mainStr = " select    USER_ID  from EG_EIS_EMPLOYEEINFO ev  where ev.POS_ID = :pos and ((ev.to_Date is null and ev.from_Date <= SYSDATE ) OR (ev.from_Date <= SYSDATE AND ev.to_Date > SYSDATE))";
        Query qry = getCurrentSession().createSQLQuery(mainStr).addScalar("USER_ID", IntegerType.INSTANCE);

        if (pos != null) {
            qry.setEntity("pos", pos);
        }
        if (qry.list() != null && !qry.list().isEmpty()) {
            for (Iterator iter = qry.list().iterator(); iter.hasNext();) {
                Long userId = (Long) iter.next();
                uerImpl = userService.getUserById(userId);
            }
        }
    } catch (HibernateException he) {
        throw new ApplicationRuntimeException(STR_EXCEPTION + he.getMessage(), he);
    } catch (Exception he) {
        throw new ApplicationRuntimeException(STR_EXCEPTION + he.getMessage(), he);
    }
    return uerImpl;

}

From source file:org.egov.pims.service.EmployeeServiceImpl.java

License:Open Source License

public PersonalInformation getEmployeeforPosition(Position pos) {
    User uerImpl = null;//  w w  w .  ja v a 2 s .  c o m
    PersonalInformation personalInformation = new PersonalInformation();
    try {

        String mainStr = "";
        mainStr = " select    id  from EG_EIS_EMPLOYEEINFO ev  where ev.POS_ID = :pos and ((ev.to_Date is null and ev.from_Date <= SYSDATE ) OR (ev.from_Date <= SYSDATE AND ev.to_Date > SYSDATE))";
        Query qry = getCurrentSession().createSQLQuery(mainStr).addScalar("id", IntegerType.INSTANCE);
        ;

        if (pos != null) {
            qry.setEntity("pos", pos);
        }
        if (qry.list() != null && !qry.list().isEmpty()) {
            for (Iterator iter = qry.list().iterator(); iter.hasNext();) {
                Integer id = (Integer) iter.next();
                personalInformation = EisManagersUtill.getEmployeeService().getEmloyeeById(id);
            }
        }
    } catch (HibernateException he) {
        LOGGER.error(he);
        throw new ApplicationRuntimeException("Exception:" + he.getMessage(), he);
    } catch (Exception he) {
        LOGGER.error(he);
        throw new ApplicationRuntimeException("Exception:" + he.getMessage(), he);
    }
    return personalInformation;

}

From source file:org.egov.ptis.domain.dao.demand.PtDemandHibernateDao.java

License:Open Source License

/**
 * This method called getCurrentDemandforProperty gets Total Current Demand Amount .
 * <p>/*from w  w w.  j  a  v  a  2  s  . c o m*/
 * This method returns Total Current Demand for given property.
 * </p>
 *
 * @param org .egov.ptis.property.model.Property property
 * @return a BigDecimal.
 */

@Override
public BigDecimal getCurrentDemandforProperty(final Property property) {

    BigDecimal currentDemand = BigDecimal.ZERO;
    Query qry = null;
    if (property != null) {
        qry = getCurrentSession().createQuery(
                " select sum(DmdDetails.amount) from  EgptPtdemand egDemand left join  egDemand.egDemandDetails DmdDetails where "
                        + " egDemand.egptProperty =:property  and egDemand.isHistory='N'   ");
        qry.setEntity(PROPERTY, property);
        currentDemand = (BigDecimal) qry.uniqueResult();
    }

    return currentDemand;

}

From source file:org.egov.ptis.domain.dao.demand.PtDemandHibernateDao.java

License:Open Source License

/**
 * This method called WhetherBillExistsForProperty gets Character .
 * <p>//w w  w. java 2s.  com
 * This method returns Character for given Property , billnum and Module.
 * </p>
 *
 * @param org .egov.ptis.property.model.Property property
 * @param java .lang.Integer billnum
 * @param org .egov.infstr.commons.Module module
 * @return Character of 'Y' or 'N'.
 */

@SuppressWarnings("unchecked")
@Override
public Character whetherBillExistsForProperty(final Property property, final String billnum,
        final Module module) {
    Character status = null;
    Query qry = null;
    List<EgBill> list;
    if (property != null && billnum != null) {
        final List<EgBill> egBillList = demandGenericDAO.getBillsByBillNumber(billnum, module);
        if (egBillList == null || egBillList.isEmpty())
            status = 'N';
        else {
            final EgBill egBill = egBillList.get(0);
            if (egBill == null)
                status = 'N';
            else {
                qry = getCurrentSession().createQuery(
                        "select egBill from  EgptPtdemand egptDem , EgBill egBill  where egptDem.egptProperty =:property and :egBill in elements(egptDem.egBills)   ");
                qry.setEntity(PROPERTY, property);
                qry.setEntity("egBill", egBill);
                list = qry.list();
                if (list.isEmpty())
                    status = 'N';
                else
                    status = 'Y';
            }
        }
    }
    return status;
}

From source file:org.egov.ptis.domain.dao.demand.PtDemandHibernateDao.java

License:Open Source License

/**
 * This method called getNonHistoryDemandForProperty gets EgptPtdemand Object which is NonHistory.
 * <p>//from   w w  w  .  j  a va  2 s  .  c  o m
 * This method returns EgptPtdemand Object for given property .
 * </p>
 *
 * @param org .egov.ptis.property.model.Property property
 * @return EgptPtdemand Object.
 */

@Override
public Ptdemand getNonHistoryDemandForProperty(final Property property) {
    Query qry = null;
    Ptdemand egptPtdemand = null;

    if (property != null) {
        qry = getCurrentSession()
                .createQuery("from  Ptdemand egptDem where egptDem.egptProperty =:property   ");
        qry.setEntity(PROPERTY, property);
        if (qry.list().size() == 1)
            egptPtdemand = (Ptdemand) qry.uniqueResult();
        else
            egptPtdemand = (Ptdemand) qry.list().get(0);
    }
    return egptPtdemand;
}

From source file:org.egov.ptis.domain.dao.demand.PtDemandHibernateDao.java

License:Open Source License

/**
 * This method called getDmdDetailsByPropertyIdBoundary gets DemandDetails List .
 * <p>/*from   w ww  .ja va  2  s  .com*/
 * This method returns DemandDetails List for given BasicProperty Object & Boundary Object(Optional) .
 * </p>
 *
 * @param org .egov.ptis.property.model.BasicProperty basicProperty
 * @param org .egov.lib.admbndry.Boundary divBoundary
 * @return DemandDetails List.
 */

// Here divBoundary is used because in some Property Tax Applications(like
// COC) propertyId is not unique ,It is unique within the Division Boundary
// check the demandReasonMaster list . It is not working
@SuppressWarnings("rawtypes")
@Override
public List getDmdDetailsByPropertyIdBoundary(final BasicProperty basicProperty, final Boundary divBoundary) {
    String divStatus = "N";
    List list = new ArrayList();
    final StringBuilder qry = new StringBuilder(50);
    if (basicProperty != null) {
        // should check for active
        qry.append(" select demdet From EgptPtdemand ptdem left join ptdem.egDemandDetails demdet left join "
                + "ptdem.egptProperty prop left join  prop.basicProperty bp");
        if (divBoundary != null) {
            qry.append(" left join bp.propertyID ppid  ");
            divStatus = "Y";
        }

        qry.append(
                " where ptdem.isHistory='N'  and prop.status='N' and  prop.isDefaultProperty='Y' and bp.active='Y' "
                        + "and bp =:basicProperty ");
        if ("Y".equals(divStatus))
            qry.append(" and ppid.wardId =:divBoundary  ");

        final Query query = getCurrentSession().createQuery(qry.toString());
        query.setEntity("basicProperty", basicProperty);
        if ("Y".equals(divStatus))
            query.setEntity("divBoundary", divBoundary);
        list = query.list();
    }
    return list;
}

From source file:org.egov.ptis.domain.dao.demand.PtDemandHibernateDao.java

License:Open Source License

@SuppressWarnings("rawtypes")
public List getTransactionByBasicProperty(final BasicProperty basicProperty, final Installment installment,
        final String is_cancelled) {
    Query qry = null;
    List list = new ArrayList(0);
    if (basicProperty != null && installment != null && is_cancelled != null && !is_cancelled.equals("")) {
        qry = getCurrentSession().createQuery(
                " select TD from PropertyTaxTxAgent txAgent left join txAgent.myTransactions header "
                        + " left join header.transactionDetails TD where  header.isCancelled =:is_cancelled and "
                        + " header.installment =:installment and txAgent.basicProperty =:basicProperty  ");
        qry.setString("is_cancelled", is_cancelled);
        qry.setEntity("basicProperty", basicProperty);
        qry.setEntity("installment", installment);
        list = qry.list();/*from w  w  w. jav  a 2 s. c o m*/
    }
    return list;
}

From source file:org.egov.ptis.domain.dao.demand.PtDemandHibernateDao.java

License:Open Source License

/**
 * This method returns current installment non-history EgptPtdemand
 * <p>/*from   w  ww .j  a v  a  2 s.  c  o  m*/
 * This method returns EgptPtdemand Object for given property .
 * </p>
 *
 * @param org .egov.ptis.property.model.Property property
 * @return EgptPtdemand Object.
 */
@Override
public Ptdemand getNonHistoryCurrDmdForProperty(final Property property) {
    Query qry = null;
    Ptdemand egptPtdemand = null;

    if (property != null) {
        final CFinancialYear currentFinancialYear = financialYearDAO.getFinancialYearByDate(new Date());
        qry = getCurrentSession().createQuery(
                "from  Ptdemand egptDem left join fetch egptDem.egDemandDetails dd left join fetch dd.egDemandReason dr "
                        + "where egptDem.egptProperty =:property "
                        + "and (egptDem.egInstallmentMaster.fromDate <= :fromYear and egptDem.egInstallmentMaster.toDate >=:toYear) and egptDem.isHistory='N' ");
        qry.setEntity(PROPERTY, property);
        qry.setDate("fromYear", currentFinancialYear.getStartingDate());
        qry.setDate("toYear", currentFinancialYear.getStartingDate());
        final List<Ptdemand> ptDemandResult = qry.list();
        if (!ptDemandResult.isEmpty())
            egptPtdemand = ptDemandResult.get(0);
    }
    return egptPtdemand;
}