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.ptis.domain.dao.property.PropertyDetailHibernateDAO.java

License:Open Source License

@Override
public PropertyDetail getPropertyDetailByRegNum(String regNum) {
    LOGGER.info("getPropertyDetailByRegNum Invoked");

    BasicProperty basicProperty = basicPropertyDAO.getBasicPropertyByRegNum(regNum);

    LOGGER.info("basicProperty : " + basicProperty);

    Query qry = getCurrentSession().createQuery("from PropertyImpl P where P.basicProperty = :BasicProperty ");
    qry.setEntity("BasicProperty", basicProperty);
    Property property = (Property) qry.uniqueResult();
    LOGGER.info("property : " + property);
    Query qry1 = getCurrentSession().createQuery("from PropertyDetail PD where PD.property =:Property ");
    qry1.setEntity("Property", property);

    return (PropertyDetail) qry1.uniqueResult();
}

From source file:org.egov.ptis.domain.dao.property.PropertyHibernateDAO.java

License:Open Source License

@Override
public Property getPropertyByBasicPropertyID(BasicProperty basicProperty) {
    Query qry = getCurrentSession().createQuery("from PropertyImpl P where P.basicProperty =:basicProperty");
    qry.setEntity("basicProperty", basicProperty);
    qry.setMaxResults(1);/*from   w  w w .  ja  v  a  2  s. c  om*/
    return (Property) qry.uniqueResult();
}

From source file:org.egov.ptis.domain.dao.property.PropertyHibernateDAO.java

License:Open Source License

@Override
public List getAllNonDefaultProperties(BasicProperty basicProperty) {
    Query qry = getCurrentSession().createQuery(
            "from PropertyImpl P where P.basicProperty =:basicProperty and P.isDefaultProperty='N' and P.status='N' ");
    qry.setEntity("basicProperty", basicProperty);
    return qry.list();
}

From source file:org.egov.ptis.domain.dao.property.PropertyHibernateDAO.java

License:Open Source License

@Override
public List getAllProperties(BasicProperty basicProperty) {
    Query qry = getCurrentSession()
            .createQuery("from PropertyImpl P where P.basicProperty =:basicProperty  and P.status='N' ");
    qry.setEntity("basicProperty", basicProperty);
    return qry.list();
}

From source file:org.egov.ptis.domain.dao.property.PropertyHibernateDAO.java

License:Open Source License

/**
 * This is used to get a unique property based on 3 parameters
 * BasicProperty,assessmentYearand ProeprtySource, may throw exception in
 * case of multiple resultset./*from   w w w  .  ja v a 2 s .  com*/
 */
@Override
public Property getPropertyForInstallment(BasicProperty basicProperty, Installment insatllment,
        PropertySource src) {
    try {
        Property prop = null;
        Query qry = getCurrentSession().createQuery(
                "from PropertyImpl P where  P.basicProperty =:basicProperty  and P.status='N' and P.installment=:insatllment and P.propertySource =:src ");
        qry.setEntity("insatllment", insatllment);
        qry.setEntity("basicProperty", basicProperty);
        qry.setEntity("src", src);
        if (qry.uniqueResult() != null) {
            prop = (Property) qry.uniqueResult();
            LOGGER.debug("getPropertyForInstallment : prop : " + prop);
        }
        return prop;
    } catch (Exception e) {
        LOGGER.error("Exception in  getPropertyForInstalment in DAO : " + e.getMessage());
        throw new ApplicationRuntimeException("Exception in  getPropertyForInstalment" + e);
    }
}

From source file:org.egov.ptis.domain.dao.property.PropertyHibernateDAO.java

License:Open Source License

@Override
public List getAllHistories(BasicProperty bp, PropertySource src) {
    Query qry = getCurrentSession().createQuery(
            "from PropertyImpl P where P.basicProperty =:basicProperty and P.status='Y' and P.propertySource =:src ");
    qry.setEntity("basicProperty", bp);
    qry.setEntity("src", src);
    return qry.list();
}

From source file:org.egov.ptis.domain.dao.property.PropertyHibernateDAO.java

License:Open Source License

@Override
public List getAllPropertiesForGivenBndryListSrcAndInst(final List bndryList, final String src,
        final Installment inst) {
    List propList = new ArrayList(0);
    if (bndryList != null && !bndryList.isEmpty() && src != null && !src.isEmpty() && inst != null) {
        LOGGER.debug("getAllPropertiesForGivenBndryListSrcAndInst : bndryList : " + bndryList + " : src : "
                + src + " : inst : " + inst);
        final Query qry = getCurrentSession().createQuery(
                "select prop from BasicPropertyImpl BP, PropertyImpl prop left join prop.propertySource propsrc "
                        + "where prop.basicProperty.id = BP.id and propsrc.name like :src and prop.propertyDetail.installment=:inst and BP.boundary.id in (:bndryList)");
        qry.setString("src", src);
        qry.setEntity("inst", inst);
        qry.setParameterList("bndryList", bndryList);
        propList = qry.list();/*  w  ww  .  j a va2s  .  co m*/
    }
    LOGGER.debug("getAllPropertiesForGivenBndryListSrcAndInst propList() : " + propList.size());
    return propList;
}

From source file:org.egov.ptis.domain.dao.property.PropertyHibernateDAO.java

License:Open Source License

@Override
public List getAllNonHistoryPropertiesForSrc(final BasicProperty basicProperty, final PropertySource src) {
    List propList = new ArrayList(0);
    if (basicProperty != null && src != null) {
        final Query qry = getCurrentSession().createQuery(
                "from PropertyImpl P where P.basicProperty =:basicProperty and P.status='N' and P.propertySource =:src");
        qry.setEntity("basicProperty", basicProperty);
        qry.setEntity("src", src);
        propList = qry.list();/*from  w w w  .j a va 2s.co m*/
    }
    LOGGER.debug("getAllNonHistoryPropertiesForSrc propList() : " + propList.size());
    return propList;
}

From source file:org.egov.ptis.domain.dao.property.PropertyHibernateDAO.java

License:Open Source License

@Override
public Property getPropertyBySrcAndBp(final BasicProperty basicProperty, final PropertySource src)
        throws ApplicationRuntimeException {
    Property prop = null;//from  w  w w.  j ava  2s  . c om
    try {
        if (basicProperty != null && src != null) {
            LOGGER.debug("getPropertyBySrcAndBp basicProperty : " + basicProperty);
            final Query qry = getCurrentSession().createQuery(
                    "from PropertyImpl P where P.basicProperty =:basicProperty and  P.status='N' and P.propertySource =:src");
            qry.setEntity("basicProperty", basicProperty);
            qry.setEntity("src", src);
            prop = (Property) qry.uniqueResult();
        }
        return prop;
    } catch (final Exception e) {
        LOGGER.error("Exception in getPropertyBySrcAndBp : " + e.getMessage());
        throw new ApplicationRuntimeException("Exception in  getPropertyBySrcAndBp", e);
    }
}

From source file:org.egov.ptis.domain.dao.property.PropertyHibernateDAO.java

License:Open Source License

/**
 * This is used to get all the proposed arv's for that particular property.
 *///from  w  ww .  ja v a 2s  . c om
@Override
public List getPtDemandArvProposedList(final Property property) {
    final Query qry = getCurrentSession().createQuery(
            "from PtDemandARV arv where arv.property =:property  and arv.isHistory='N' and arv.type='Proposed' ");
    qry.setEntity("property", property);
    return qry.list();
}