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

License:Open Source License

@Override
public BasicProperty getBasicPropertyByPropertyID(PropertyID propertyID) {

    Query qry = getCurrentSession()
            .createQuery("from BasicPropertyImpl BP where BP.propertyID =:PropertyID and BP.active='Y' ");
    qry.setEntity("PropertyID", propertyID);
    return (BasicProperty) qry.uniqueResult();
}

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

License:Open Source License

@Override
public Category getCategoryForBoundary(Boundary bndry) {
    Category category = null;//from   w  ww  . j av  a  2  s.co m
    Query qry = null;
    if (bndry != null) {
        qry = getCurrentSession().createQuery(
                "select C from Category C inner join C.catBoundaries BC where BC.bndry = :bndry AND ("
                        + "(BC.toDate IS NULL AND BC.fromDate <= :currDate) " + "OR "
                        + "(BC.fromDate <= :currDate AND BC.toDate >= :currDate)) ");
        qry.setEntity(BOUNDARY, bndry);
        qry.setDate("currDate", new Date());
        if (qry.list().size() == 1)
            category = (Category) qry.uniqueResult();
    }
    return category;
}

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

License:Open Source License

@Override
public Category getCategoryForBoundaryAndDate(Boundary bndry, Date date) {
    Category category = null;//from   w w w  .  j  ava2s. com
    Query qry = null;
    if (bndry != null && date != null) {
        qry = getCurrentSession().createQuery(
                "select C from Category C inner join C.catBoundaries BC where BC.bndry = :bndry AND ("
                        + "(BC.toDate IS NULL AND BC.fromDate <= :date) " + "OR "
                        + "(BC.fromDate <= :date AND BC.toDate >= :date)) ");
        qry.setEntity(BOUNDARY, bndry);
        qry.setDate("date", date);
        if (qry.list().size() == 1)
            category = (Category) qry.uniqueResult();
    }
    return category;
}

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

License:Open Source License

@Override
public BoundaryCategory getBoundaryCategoryByBoundry(Boundary bndry) {
    BoundaryCategory bndryCategory = null;
    Query qry = null;
    if (bndry != null) {
        qry = getCurrentSession().createQuery("from BoundaryCategory BC where BC.bndry = :bndry AND ("
                + "(BC.toDate IS NULL AND BC.fromDate <= :currDate) " + "OR "
                + "(BC.fromDate <= :currDate AND BC.toDate >= :currDate)) ");
        qry.setEntity(BOUNDARY, bndry);
        qry.setDate("currDate", new Date());

        if (qry.list().size() == 1)
            bndryCategory = (BoundaryCategory) qry.uniqueResult();
    }/*from w  w w . j  a v  a2s .co m*/
    return bndryCategory;
}

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

License:Open Source License

@Override
public BoundaryCategory getBoundaryCategoryByBoundryAndDate(Boundary bndry, Date date) {
    BoundaryCategory bndryCategory = null;
    Query qry = null;
    if (bndry != null && date != null) {
        qry = getCurrentSession().createQuery("from BoundaryCategory BC where BC.bndry = :bndry AND ("
                + "(BC.toDate IS NULL AND BC.fromDate <= :date) " + "OR "
                + "(BC.fromDate <= :date AND BC.toDate >= :date)) ");
        qry.setEntity(BOUNDARY, bndry);
        qry.setDate("date", date);
        if (qry.list().size() == 1)
            bndryCategory = (BoundaryCategory) qry.uniqueResult();
    }/* ww  w . ja va  2s.  c  o  m*/
    return bndryCategory;
}

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

License:Open Source License

@Override
public Category getCategoryByBoundryAndUsage(Boundary bndry, PropertyUsage propertyUsage) {
    Category category = null;/*from   w w w .  j a  v a2s. co m*/
    Query qry = null;
    if (bndry != null && propertyUsage != null) {
        qry = getCurrentSession().createQuery(
                "select C from Category C inner join C.catBoundaries BC where BC.bndry = :bndry and C.propUsage = :propertyUsage AND ("
                        + "(BC.toDate IS NULL AND BC.fromDate <= :currDate) " + "OR "
                        + "(BC.fromDate <= :currDate AND BC.toDate >= :currDate)) ");
        qry.setEntity(BOUNDARY, bndry);
        qry.setEntity("propertyUsage", propertyUsage);
        qry.setDate("currDate", new Date());
        if (qry.list().size() == 1)
            category = (Category) qry.uniqueResult();
    }
    return category;
}

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

License:Open Source License

@Override
public Category getCategoryByBoundryAndUsageAndDate(Boundary bndry, PropertyUsage propertyUsage, Date date) {
    Category category = null;/* ww w.java2s . c  om*/
    Query qry = null;
    if (bndry != null && propertyUsage != null && date != null) {
        qry = getCurrentSession().createQuery(
                "select C from Category C inner join C.catBoundaries BC where BC.bndry = :bndry and C.propUsage = :propertyUsage AND ("
                        + "(BC.toDate IS NULL AND BC.fromDate <= :date) " + "OR "
                        + "(BC.fromDate <= :date AND BC.toDate >= :date)) ");
        qry.setEntity(BOUNDARY, bndry);
        qry.setEntity("propertyUsage", propertyUsage);
        qry.setDate("date", date);
        if (qry.list().size() == 1)
            category = (Category) qry.uniqueResult();
    }
    return category;
}

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

License:Open Source License

@Override
public List<Category> getCategoriesByBoundry(Boundary bndry) {
    List<Category> list = new ArrayList<Category>();
    /*//  www .j  ava 2s .co m
     * String query = "SELECT cat.id_usage, " + "cat.id_struct_cl, " +
     * "cat.category_amnt, " + "cat.category_name, " + "bcat.id_bndry " +
     * "FROM egpt_mstr_category cat, " + "egpt_mstr_bndry_category bcat " +
     * "WHERE cat.id_category = bcat.id_category " +
     * "AND bcat.id_bndry =:bndryId ";
     */

    Query qry = getCurrentSession()
            .createQuery("select bc.category from BoundaryCategory bc where bc.bndry =:Boundary");
    qry.setEntity("Boundary", bndry);
    list = qry.list();
    return list;
}

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

License:Open Source License

@Override
public Float getCatAmntByPropertyId(String pid) {

    Query qry = getCurrentSession()
            .createQuery("select bp.boundary from BasicPropertyImpl bp where bp.upicNo like :pid");
    qry.setString("pid", pid);
    Boundary bndry = (Boundary) qry.uniqueResult();

    qry = getCurrentSession().createQuery(
            "select cat.categoryAmount from BoundaryCategory bCat left join bCat.category cat where bCat.bndry like :bndry");
    qry.setEntity("bndry", bndry);

    Float catAmnt = (Float) qry.uniqueResult();

    return catAmnt;
}

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

License:Open Source License

@Override
public PropertyDetail getPropertyDetailByProperty(Property property) {
    Query qry = getCurrentSession().createQuery("from PropertyDetail PD where PD.property = :property ");
    qry.setEntity("property", property);
    return (PropertyDetail) qry.uniqueResult();
}