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.DemandGenericHibDao.java

License:Open Source License

/**
 * This method called getDemandReasonByDemandReasonMaster gets
 * List<EgDemandReason> objects.//from   w w w.  j  av  a 2 s  .c om
 *
 * <p>
 * This method returns List<EgDemandReason> objects for given code and
 * module.
 * </p>
 *
 * @param org
 *            .egov.infstr.DCB.model.EgDemandReasonMaster
 *            egDemandReasonMaster.
 *
 * @return List<EgDemandReason> objects.
 *
 * 
 */

@Override
public List<EgDemandReason> getDemandReasonByDemandReasonMaster(EgDemandReasonMaster egDemandReasonMaster) {
    List<EgDemandReason> list = new ArrayList<EgDemandReason>();
    Query qry = null;
    if (egDemandReasonMaster != null) {
        qry = getCurrentSession().createQuery(
                " from EgDemandReason DmdReason  where  DmdReason.egDemandReasonMaster =:egDemandReasonMaster  ");
        qry.setEntity("egDemandReasonMaster", egDemandReasonMaster);
        list = qry.list();
    }
    return list;
}

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

License:Open Source License

/**
 * This method called getDmdReasonByDmdReasonMsterInstallAndMod gets
 * EgDemandReason object./*  www.ja  v a  2 s  .  c  o m*/
 *
 * <p>
 * This method returns EgDemandReason object for given demandReasonMaster ,
 * installment and module.
 * </p>
 *
 * @param org
 *            .egov.infstr.DCB.model.EgDemandReasonMaster
 *            egDemandReasonMaster.
 * 
 * @param org
 *            .egov.commons.Installment installment.
 * 
 * @param org
 *            .egov.infstr.commons.Module module.
 *
 * @return EgDemandReason object.
 *
 * 
 */

@Override
public EgDemandReason getDmdReasonByDmdReasonMsterInstallAndMod(EgDemandReasonMaster demandReasonMaster,
        Installment installment, Module module) {
    EgDemandReason egDemandReason = null;
    Query qry = null;
    if (demandReasonMaster != null && installment != null && module != null) {
        qry = getCurrentSession().createQuery(
                " select DmdReason from EgDemandReason DmdReason left join fetch DmdReason.egDemandReasonMaster reasonMaster where reasonMaster = :demandReasonMaster and reasonMaster.egModule =:module and DmdReason.egInstallmentMaster =:installment   ");
        qry.setEntity("demandReasonMaster", demandReasonMaster);
        qry.setEntity("module", module);
        qry.setEntity("installment", installment);
        if (qry.list().size() == 1)
            egDemandReason = (EgDemandReason) qry.uniqueResult();
        else if (qry.list().size() > 1)
            egDemandReason = (EgDemandReason) qry.list().get(0);

    }
    return egDemandReason;
}

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

License:Open Source License

/**
 * This method called getDemandDetailsForDemand gets List<EgDemandDetails>
 * objects.//from   w w w .  j ava  2  s. c  om
 *
 * <p>
 * This method returns List<EgDemandDetails> objects for given EgDemand and
 * EgwStatus.
 * </p>
 *
 * @param org
 *            .egov.infstr.DCB.model.EgDemand demand.
 * 
 * @param org
 *            .egov.commons.EgwStatus status.
 *
 * @return List<EgDemandDetails> objects.
 *
 * 
 */

@Override
public List<EgDemandDetails> getDemandDetailsForDemand(EgDemand demand, EgwStatus status) {
    StringBuffer qryStr = new StringBuffer(2000);
    List<EgDemandDetails> list = new ArrayList<EgDemandDetails>();
    Query qry = null;
    if (demand != null) {
        qryStr.append(
                " select DmdDetails from EgDemand egdemand left join egdemand.egDemandDetails DmdDetails  where egdemand =:demand  ");
        if (status != null) {
            qryStr.append(" and DmdDetails.egwStatus =:status ");
        }
        qry = getCurrentSession().createQuery(qryStr.toString());
        qry.setEntity("demand", demand);
        if (status != null) {
            qry.setEntity("status", status);
        }
        list = qry.list();
    }

    return list;
}

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

License:Open Source License

/**
 * This method called getDemandDetailsForDemandAndReasons gets
 * List<EgDemandDetails> objects./*w  w w.j a va2 s.c  om*/
 *
 * <p>
 * This method returns List<EgDemandDetails> objects for given EgDemand and
 * List<EgDemandReason> .
 * </p>
 *
 * @param org
 *            .egov.infstr.DCB.model.EgDemand demand.
 * 
 * @param java
 *            .util.List<org.egov.infstr.DCB.model.EgDemandReason> list.
 *
 * @return List<EgDemandDetails> objects.
 *
 * 
 */

@Override
public List<EgDemandDetails> getDemandDetailsForDemandAndReasons(EgDemand demand,
        List<EgDemandReason> demandReasonList) {
    List<EgDemandDetails> list = new ArrayList<EgDemandDetails>();
    Query qry = null;
    if (demand != null && demandReasonList != null && demandReasonList.size() > 0) {
        qry = getCurrentSession().createQuery(
                "select DmdDetails from EgDemand egdemand left join egdemand.egDemandDetails DmdDetails  where egdemand =:demand and DmdDetails.egDemandReason in (:demandReasonList) ");
        qry.setEntity("demand", demand);
        qry.setParameterList("demandReasonList", demandReasonList);
        list = qry.list();
    }
    return list;

}

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

License:Open Source License

/**
 * This method called getAllBillsForDemand gets List<EgBill> objects .
 *
 * <p>/*from w  w w .  ja v a  2 s  . c om*/
 * This method returns List<EgBill> objects for given EgDemand ,
 * includeHistory and includeCancelled .
 * </p>
 *
 * @param org
 *            .egov.infstr.DCB.model.EgDemand demand.
 * 
 * @param java
 *            .lang.String includeHistory.
 * 
 * @param java
 *            .lang.String includeCancelled.
 *
 * @return List<EgBill> objects.
 *
 * 
 */

@Override
public List<EgBill> getAllBillsForDemand(EgDemand demand, String includeHistory, String includeCancelled) {
    List<EgBill> list = new ArrayList<EgBill>();
    Query qry = null;
    StringBuffer qryStr = new StringBuffer(2000);
    if (includeHistory != null && !includeHistory.equals("") && includeHistory != null
            && !includeCancelled.equals("")) {
        qryStr.append(
                "from EgBill egBill  where  egBill.is_History =:includeHistory and egBill.is_Cancelled =:includeCancelled ");
        if (demand != null) {
            qryStr.append(" and egBill" + ".egDemand =:demand ");
        }
        qryStr.append(" order by createDate desc ");
        qry = getCurrentSession().createQuery(qryStr.toString());
        if (demand != null) {
            qry.setEntity("demand", demand);
        }
        qry.setString("includeHistory", includeHistory);
        qry.setString("includeCancelled", includeCancelled);

        list = qry.list();
    }
    return list;

}

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

License:Open Source License

/**
 * This method called getBillsByBillNumber gets List<EgBill> objects .
 *
 * <p>//w  ww . j  a v  a2  s.c  om
 * This method returns List<EgBill> objects for given BillNo and Module .
 * </p>
 *
 * @param org
 *            .egov.infstr.commons.Module module.
 * 
 * @param java
 *            .lang.Long BillNo.
 *
 * @return List<EgBill> objects.
 *
 * 
 */

@Override
public List getBillsByBillNumber(String BillNo, Module module) {
    Query qry = null;
    List<EgBill> list = new ArrayList<EgBill>();
    if (BillNo != null && !BillNo.equals("0") && module != null) {
        qry = getCurrentSession().createQuery("from EgBill egBill  where billNo =:BillNo and module =:module ");
        qry.setString("BillNo", BillNo);
        qry.setEntity("module", module);
        list = qry.list();
    }

    return list;
}

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

License:Open Source License

@Override
public DepreciationMaster getDepreciationMaster(Module mod, Integer year) {
    Query qry = getCurrentSession()
            .createQuery("from DepreciationMaster DM where DM.module=:mod and DM.year=:year ");// and
    // DM.IsHistory='N'
    // ");/*from w w  w.j  a v  a 2s.  c  o  m*/
    qry.setEntity("mod", mod);
    qry.setInteger("year", year);
    return (DepreciationMaster) qry.uniqueResult();
}

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

License:Open Source License

/**
 * Added By Rajalakshmi D.N. on 07/05/2007 Description : Returns the
 * Non-History Depreciation for the Given Module, for the given Year and for
 * the given Installment// ww w .  j  av a2 s .c o m
 * 
 * @param Module
 *            ,Year and Installment
 * @return DepreciationMaster record
 */

@Override
public DepreciationMaster getNonHistDepMasterByModuleInsYr(Module mod, Integer year, Installment insYear) {
    Query qry = getCurrentSession().createQuery(
            "from DepreciationMaster DM where DM.module=:mod and DM.year=:year and DM.IsHistory='N' and DM.startInstallment=:insYear ");
    qry.setEntity("mod", mod);
    qry.setInteger("year", year);
    qry.setEntity("insYear", insYear);
    return (DepreciationMaster) qry.uniqueResult();
}

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

License:Open Source License

@Override
public List getDepreciationsForModule(Module mod) {

    Query qry = getCurrentSession().createQuery("from DepreciationMaster DM where DM.module=:module");
    qry.setEntity("module", mod);
    return qry.list();
}

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

License:Open Source License

@Override
public List getDepreciationsForModulebyHistory(Module mod) {

    Query qry = getCurrentSession()
            .createQuery("from DepreciationMaster DM where DM.module=:module and DM.IsHistory='N'");
    qry.setEntity("module", mod);
    return qry.list();
}