List of usage examples for org.hibernate Query setEntity
@Deprecated @SuppressWarnings("unchecked") Query<R> setEntity(String name, Object val);
From source file:org.egov.ptis.domain.dao.property.PropertyHibernateDAO.java
License:Open Source License
@Override public List getPropsMrkdForDeactByWard(final Boundary boundary) throws PropertyNotFoundException { List propertyList = new ArrayList(); try {/*w ww. java 2 s . co m*/ if (boundary != null) { final Query qry = getCurrentSession() .createQuery(" select distinct bp from PropertyImpl pi " + " left join pi.basicProperty bp " + " left join bp.propertyStatusValuesSet psv " + " left join psv.propertyStatus ps " + " where bp.boundary = :boundary and pi.status='N' and bp.active='Y' " + " and ps.statusCode='MARK_DEACTIVE' and psv.isActive='Y' "); qry.setEntity("boundary", boundary); propertyList = qry.list(); } LOGGER.info("List of properties By Query" + propertyList.size()); return propertyList; } catch (final HibernateException e) { LOGGER.error("Error occured in PropertyHibernateDao.getPropsMrkdForDeactByWard" + e.getMessage()); final PropertyNotFoundException er = new PropertyNotFoundException( "Hibernate Exception In getAllPropertiesMarkedForDeactivationByWard: " + e); er.initCause(e); throw er; } catch (final Exception e) { LOGGER.error("Error occured in PropertyHibernateDao.getPropsMrkdForDeactByWard" + e.getMessage()); throw new ApplicationRuntimeException("Exception in getAllPropertiesMarkedForDeactivationByWard" + e); } }
From source file:org.egov.ptis.domain.dao.property.PropertyHibernateDAO.java
License:Open Source License
/** * API gives the latest GIS survey property for the basicproperty *//*w w w . j a v a2 s .com*/ @Override public Property getLatestGISPropertyForBasicProperty(BasicProperty basicProperty) { Query qry = getCurrentSession().createQuery( "from PropertyImpl where basicProperty =:basicProperty and status = 'G' order by id desc "); qry.setEntity("basicProperty", basicProperty); qry.setMaxResults(1); return (Property) qry.uniqueResult(); }
From source file:org.egov.ptis.domain.dao.property.PropertyHibernateDAO.java
License:Open Source License
/** * API gives the history property for the basicproperty *//*w w w . j ava 2 s. c o m*/ @Override public Property getHistoryPropertyForBasicProperty(BasicProperty basicProperty) { Query qry = getCurrentSession().createQuery( "from PropertyImpl where basicProperty =:basicProperty and status = 'H' order by id desc "); qry.setEntity("basicProperty", basicProperty); qry.setMaxResults(1); return (Property) qry.uniqueResult(); }
From source file:org.egov.ptis.domain.dao.property.PropertyHibernateDAO.java
License:Open Source License
/** * API gives the latest Demand for history property *//* w ww. j a v a2 s .co m*/ public Ptdemand getLatestDemand(Property oldProperty) { Query qry = getCurrentSession().createQuery( "from Ptdemand where egptProperty =:oldProperty and isHistory='N' order by egInstallmentMaster.installmentYear desc"); qry.setEntity("oldProperty", oldProperty); qry.setMaxResults(1); return (Ptdemand) qry.uniqueResult(); }
From source file:org.egov.ptis.domain.dao.property.SearchPropertyHibernateDAO.java
License:Open Source License
@Override public List getPropertyByBoundryAndOwnerName(Integer boundryID, String ownerName, String phNumber) throws PropertyNotFoundException { if (boundryID == null) { throw new ApplicationRuntimeException("Parameters not Set during PropertySearch based on Boundry!!"); }/*from www . j ava 2 s. co m*/ Query qry; try { LOGGER.info("Executing testChequeQry query................................................"); Boundary boundary = boundaryService.getBoundaryById(boundryID.longValue()); LOGGER.info("testQry executed......................................................"); // seems to be best. other thing is add distinct to the query to not // get duplicate recored (since the // query yields to a cartiesian product). // qrySecTest = // session.createQuery("From PropertyImpl pi where pi.id_Adm_Bndry = // :boundryID and pi.propertyOwnerSet.firstName like :firstName"); StringBuffer qryStr = new StringBuffer(2000); LOGGER.info("-----------search by boundary--------"); qryStr.append( "select distinct pi From PropertyImpl pi left join fetch pi.basicProperty bp where bp.boundary = :boundary and pi.status='A' and pi.isDefaultProperty='Y' and bp.active='Y' ");// order // by // bp.upicNo // asc LOGGER.info("searching for boundary" + qryStr.toString() + "boundaryId" + boundryID); qry = getCurrentSession().createQuery(qryStr.toString()); // ownername is available create query and set ownername if (ownerName != null && !ownerName.equals("")) { boolean phNumFound = false; qryStr.append( " and (pi.propertyOwnerSet.firstName like :firstName or pi.propertyOwnerSet.middleName like :firstName or pi.propertyOwnerSet.lastName like :firstName )");// or // pi.propertyOwnerSet.Owner.middleName // like // :middleName // or // pi.propertyOwnerSet.Owner.lastName // like // :lastName LOGGER.info("Query String for ownername" + qryStr.toString() + " ........ " + ownerName + "///////" + ownerName); qry = getCurrentSession().createQuery(qryStr.toString()); // phoneNumber is not null create query and set phone number to // that. if (phNumber != null && !phNumber.equals("")) { phNumFound = true; qryStr.append( " and (pi.propertyOwnerSet.homePhone =:homePhone or pi.propertyOwnerSet.officePhone =:homePhone or pi.propertyOwnerSet.mobilePhone =:homePhone)"); LOGGER.info("----------Searching With Phnumber-----" + qryStr.toString()); LOGGER.debug("allvalues set for phnumber"); } qryStr.append(" order by bp.upicNo asc"); qry = getCurrentSession().createQuery(qryStr.toString()); qry.setString("firstName", ownerName + "%");// ptisCacheInterface.encodingName(ownerName) if (phNumFound) { qry.setString("homePhone", phNumber); } LOGGER.debug("allvalues set for ownerFullName"); } qry.setEntity("boundary", boundary); List propertyList = qry.list(); LOGGER.info("query given list of props" + propertyList.size()); if (propertyList != null) { return getSearchResultList(propertyList); } else { throw new PropertyNotFoundException( "Internal Server Error in Searching Property Based on Colony No,Please Try Later !!"); } } catch (HibernateException e) { PropertyNotFoundException exception = new PropertyNotFoundException( "Hibernate Exception In getPropertyByBoundryAndOwnerName: " + e.getMessage()); exception.initCause(e); throw exception; } catch (PropertyNotFoundException e) { LOGGER.error("PropertyNotFoundException in getPropertyByBoundryAndOwnerName : " + e.getMessage()); throw new PropertyNotFoundException("Exception in getPropertyByBoundryAndOwnerName"); } catch (Exception e) { LOGGER.error("Exception in getPropertyByBoundryAndOwnerName : " + e.getMessage()); throw new ApplicationRuntimeException("Exception in getPropertyByBoundryAndOwnerName"); } }
From source file:org.egov.ptis.domain.dao.property.SearchPropertyHibernateDAO.java
License:Open Source License
@Override public List getPropertyByRvAmout(Integer boundaryID, Character RvSel, String lowVal, String HighVal) throws PropertyNotFoundException { LOGGER.info(">>>>>>>>>>inside getPropertyByRvAmout>>>>>>>>>>>>>>"); if (RvSel == null || RvSel.equals("")) { throw new ApplicationRuntimeException( "RV amout selection was not Set during PropertySearch based on Boundry!!"); }/*from w w w .ja va2s . c o m*/ LOGGER.info("after query execution--------------RvSel--" + RvSel.charValue() + "---------lowVal----------" + lowVal + "--------HighVal--------" + HighVal); Query qry; try { LOGGER.info("Executing testChequeQry query..............."); Boundary boundary = boundaryService.getBoundaryById(boundaryID.longValue()); java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd/MM/yyyy"); String finEndDate = sdf.format(new Date());//TODO WHEN REQUIRED removing getFinancialYear sdf.format(DateUtils.getFinancialYear().getEndOnOnDate()); StringBuffer qryStr = new StringBuffer(2000); qryStr.append("select distinct pi From PropertyImpl pi inner join pi.basicProperty bp inner join " + "pi.ptDemandARVSet rv where rv.toDate = to_date('" + finEndDate + "','dd/mm/yyyy') and " + "pi.status='A' and bp.active='Y' "); boolean rvLess = false; boolean rvGreater = false; boolean rvBetween = false; boolean rvEqual = false; boolean seatFound = false; if (boundaryID != null && boundaryID.intValue() != 0) { seatFound = true; qryStr.append(" and bp.boundary = :boundary"); LOGGER.info( ">>>>>>>>>>>>>>Search by seat no>>>>>>>>>>>>> " + qryStr.toString() + "....." + boundaryID); } if (RvSel.charValue() == '1') { rvLess = true; qryStr.append(" and rv.arv <= :highVal "); LOGGER.info(">>>>>>>>>>>>>>Search by arv amount rvsel--- 1"); } if (RvSel.charValue() == '2') { rvGreater = true; qryStr.append(" and rv.arv >= :lowVal "); LOGGER.info(">>>>>>>>>>>>>>Search by arv amount rvsel--- 2"); } if (RvSel.charValue() == '3') { rvBetween = true; qryStr.append(" and rv.arv >= :lowVal and rv.arv <= :highVal "); LOGGER.info(">>>>>>>>>>>>>>Search by arv amount rvsel--- 3"); } if (RvSel.charValue() == '4') { rvEqual = true; qryStr.append(" and rv.arv = :lowVal "); LOGGER.info(">>>>>>>>>>>>>>Search by arv amount rvsel--- 2"); } LOGGER.info("query string final--------------" + qryStr.toString()); qry = getCurrentSession().createQuery(qryStr.toString()); if (seatFound) { qry.setEntity("boundary", boundary); } if (rvLess) { qry.setBigDecimal("highVal", new BigDecimal(HighVal)); } if (rvGreater) { qry.setBigDecimal("lowVal", new BigDecimal(lowVal)); } if (rvBetween) { qry.setBigDecimal("lowVal", new BigDecimal(lowVal)); qry.setBigDecimal("highVal", new BigDecimal(HighVal)); } if (rvEqual) { qry.setBigDecimal("lowVal", new BigDecimal(lowVal)); } LOGGER.info("before query execution"); List propertyList = qry.list(); if (propertyList == null) { throw new PropertyNotFoundException( "No Properties Found with the matching Criteria: lowval:" + lowVal + ",highval:" + HighVal); } else { if (propertyList.size() > 200) { List errorList = new ArrayList(); errorList.add(0, "more props"); return errorList; } return getSearchResultList(propertyList); } } catch (Exception e) { LOGGER.info("Excetion in getPropertyByRvAmout----------------" + e); throw new ApplicationRuntimeException("Error in getPropertyByRvAmout", e); } }
From source file:org.egov.ptis.domain.dao.property.SearchPropertyHibernateDAO.java
License:Open Source License
/** * This method called getPropertyByMobileNumber gets List of Property * Objects//from w w w .java2s . c o m * * <p> * This method returns List of Property Objects for given mobile Number. * </p> * * @param java * .lang.String mobileNum * * @throws org.egov.ptis.PropertyNotFoundException. */ @Override public List getPropertyByMobileNumber(String mobileNum) throws PropertyNotFoundException { List propList = new ArrayList(); StringBuffer qryStr = new StringBuffer(2000); try { Module module = moduleDao.getModuleByName(PropertyTaxConstants.PTMODULENAME); Installment installment = installmentDao.getInsatllmentByModuleForGivenDate(module, new Date()); if (mobileNum != null && !mobileNum.equals("")) { Query qry = null; qryStr.append( "select distinct pi From PropertyImpl pi left join fetch pi.basicProperty bp left join fetch bp.address ad where ad.mobileNo like :mobileNum and pi.status='A' and pi.installment = :Installment "); qry = getCurrentSession().createQuery(qryStr.toString()); qry.setString("mobileNum", "%" + mobileNum + "%"); qry.setEntity("Installment", installment); propList = qry.list(); } } catch (Exception e) { LOGGER.error("Exception in getPropertyByMobileNumber : " + e.getMessage()); throw new ApplicationRuntimeException("Exception in getPropertyByMobileNumber"); } return propList; }
From source file:org.egov.ptis.domain.dao.property.SearchPropertyHibernateDAO.java
License:Open Source License
/** * This method called getPropertyByBillNumber gets List of Property Objects * //from w w w . j a v a 2s .c o m * <p> * This method returns List of Property Objects for given billNumber. * </p> * * @param java * .lang.String billNumber * * @throws org.egov.ptis.PropertyNotFoundException. */ @Override public List getPropertyByBillNumber(String billNumber) throws PropertyNotFoundException { List propList = new ArrayList(); StringBuffer qryStr = new StringBuffer(2000); try { if (billNumber != null && !billNumber.equals("")) { // Getting current installment property always Module module = moduleDao.getModuleByName(PropertyTaxConstants.PTMODULENAME); Installment installment = installmentDao.getInsatllmentByModuleForGivenDate(module, new Date()); Query qry = null; qryStr.append( "From PropertyImpl pi left join fetch pi.basicProperty bp where bp.upicNo like :billNumber and pi.isDefaultProperty='Y' and pi.status='A' and pi.installment = :Installment "); qry = getCurrentSession().createQuery(qryStr.toString()); qry.setString("billNumber", billNumber + "%"); qry.setEntity("Installment", installment); propList = qry.list(); } } catch (Exception e) { LOGGER.error("Exception in getPropertyByBillNumber : " + e.getMessage()); throw new ApplicationRuntimeException("Exception in getPropertyByBillNumber"); } return propList; }
From source file:org.egov.ptis.domain.dao.property.SearchPropertyHibernateDAO.java
License:Open Source License
/** * This method called getPropertyByBoundryAndOwnerNameAndHouseNo gets List * of Property Objects/*from w w w . j a va 2s .c o m*/ * * <p> * This method returns List of Property Objects for given * boundaryId,ownerName,newHouseNo.,oldHouseNo. . * </p> * * @param java * .lang.Integer boundryID * * @param java * .lang.String ownerName * * @param java * .lang.String houseNo * * @param java * .lang.String oldHouseNo * * @throws org.egov.ptis.PropertyNotFoundException. */ @Override public List getPropertyByBoundryAndOwnerNameAndHouseNo(Integer boundryID, String ownerName, String newHouseNo, String oldHouseNo) throws PropertyNotFoundException { Query qry; List propertyList = new ArrayList(); try { if (boundryID != null && !boundryID.equals("")) { Boundary boundary = boundaryService.getBoundaryById(boundryID.longValue()); LOGGER.info("boundary.obj................" + boundary); StringBuffer qryStr = new StringBuffer(2000); qryStr.append( "select distinct pi From PropertyImpl pi left join fetch pi.basicProperty bp left join fetch bp.propertyID ppid left join pi.propertyOwnerSet ownerSet where pi.status='A' and pi.isDefaultProperty='Y' and bp.active='Y' "); LOGGER.info("searching for boundary " + qryStr.toString() + "boundaryId" + boundryID); boolean bndryFound = false; boolean wardBndryFound = false; boolean areaBndryFound = false; boolean ownerFound = false; boolean houseFound = false; boolean oldHouseNum = false; if (boundary != null) { String boundryType = boundary.getBoundaryType().getName(); LOGGER.info("testQry executed.......boundryType................." + boundryType); if (boundryType != null && boundryType.endsWith("Ward")) { wardBndryFound = true; qryStr.append(" and ppid.ward = :boundary"); } else if (boundryType != null && boundryType.endsWith("Area")) { areaBndryFound = true; qryStr.append(" and ppid.area = :boundryID"); } else if (boundryType != null && boundryType.endsWith("Locality")) { bndryFound = true; qryStr.append(" and ppid.locality = :boundryID"); } else if (boundryType != null && boundryType.endsWith("Street")) { bndryFound = true; qryStr.append(" and ppid.street = :boundryID"); } } if (ownerName != null && !ownerName.equals("")) { ownerFound = true; qryStr.append( " and (upper(ownerSet.firstName) like :firstName or upper(ownerSet.middleName) like :firstName or upper(ownerSet.lastName) like :firstName) "); // :lastName } if (newHouseNo != null && !newHouseNo.equals("")) { houseFound = true; qryStr.append(" and (upper(pi.basicProperty.address.houseNo) like :houseno ) "); } if (oldHouseNo != null && !oldHouseNo.equals("")) { oldHouseNum = true; qryStr.append(" and (upper(pi.basicProperty.address.doorNumOld) like :oldHouseNo) "); } qryStr.append(" order by bp.id "); LOGGER.debug("query string final--------------" + qryStr.toString()); qry = getCurrentSession().createQuery(qryStr.toString()); if (wardBndryFound) { qry.setEntity("boundary", boundary); } if (areaBndryFound) { qry.setInteger("boundryID", boundryID); } if (bndryFound) { qry.setInteger("boundryID", boundryID); } if (ownerFound) { qry.setString("firstName", "%" + ownerName.toUpperCase() + "%"); } if (houseFound) { qry.setString("houseno", newHouseNo.toUpperCase() + "%"); } if (oldHouseNum) { qry.setString("oldHouseNo", oldHouseNo.toUpperCase() + "%"); } propertyList = qry.list(); } return propertyList; } catch (Exception e) { throw new ApplicationRuntimeException("Error in getPropertyByBoundryAndOwnerNameAndHouseNo", e); } }
From source file:org.glite.security.voms.admin.persistence.dao.VOMSAttributeDAO.java
License:Apache License
public boolean isAttributeValueAlreadyAssigned(VOMSUser u, VOMSAttributeDescription desc, String attrValue) { if (!desc.isUnique()) return false; String queryString = "select a.value from VOMSUser u join u.attributes a where a.attributeDescription = :desc " + "and u != :user"; Query q = HibernateFactory.getSession().createQuery(queryString); q.setEntity("desc", desc); q.setEntity("user", u); // Need to perform the check in memory since oracle has a bug (or I did // not understand how to manage clob equality tests). Iterator i = q.iterate();/*from w ww. j av a 2s. c o m*/ while (i.hasNext()) { String value = (String) i.next(); // NULL attribute value can be assigned to multiple users, two NULLs // aren't equal as attribute values if (value == null) return false; if (value.equals(attrValue)) return true; } return false; }