use of org.hibernate.Query in project head by mifos.
the class LegacyLoanDao method getLoanAccountsInActiveBadStanding.
@SuppressWarnings("unchecked")
public List<LoanBO> getLoanAccountsInActiveBadStanding(final Short branchId, final Short loanOfficerId, final Short loanProductId) throws PersistenceException {
String activeBadAccountIdQuery = "from org.mifos.accounts.loan.business.LoanBO loan where loan.accountState.id = 9";
StringBuilder queryString = loanQueryString(branchId, loanOfficerId, loanProductId, activeBadAccountIdQuery);
try {
Session session = StaticHibernateUtil.getSessionTL();
Query query = session.createQuery(queryString.toString());
return query.list();
} catch (Exception e) {
throw new PersistenceException(e);
}
}
use of org.hibernate.Query in project head by mifos.
the class LegacyMasterDao method getLookUpEntity.
/**
* Only two non-test usages, one that may never be called and one for getting labels.
*/
@Transactional
public CustomValueDto getLookUpEntity(final String entityName) throws SystemException {
Session session = getSession();
Query queryEntity = session.getNamedQuery("masterdata.entityvalue");
queryEntity.setString("entityType", entityName);
CustomValueDto entity = (CustomValueDto) queryEntity.uniqueResult();
entity.setCustomValueListElements(lookUpValue(entityName, session));
return entity;
}
use of org.hibernate.Query in project head by mifos.
the class LegacyMasterDao method getCustomValueListElements.
@SuppressWarnings("unchecked")
private List<CustomValueListElementDto> getCustomValueListElements(final String entityName, final String entityClass, final String column, final Session session) {
Query queryEntity = session.createQuery("select new org.mifos.application.master.business.CustomValueListElementDto(" + "mainTable." + column + " ,lookup.lookUpId,lookupvalue.lookUpValue,lookup.lookUpName) " + "from org.mifos.application.master.business.LookUpValueEntity lookup," + "org.mifos.application.master.business.LookUpValueLocaleEntity lookupvalue," + entityClass + " mainTable " + "where mainTable.lookUpId = lookup.lookUpId" + " and lookup.lookUpEntity.entityType = ?" + " and lookup.lookUpId = lookupvalue.lookUpId" + " and lookupvalue.localeId = ?");
queryEntity.setString(0, entityName);
queryEntity.setShort(1, (short) 1);
List<CustomValueListElementDto> entityList = queryEntity.list();
return entityList;
}
use of org.hibernate.Query in project head by mifos.
the class CustomerDaoHibernate method updateLoanOfficersForAllChildrenAndAccounts.
@Override
public void updateLoanOfficersForAllChildrenAndAccounts(Short parentLO, String parentSearchId, Short parentOfficeId) {
String hql = "update CustomerBO customer " + " set customer.personnel.personnelId = :parentLoanOfficer " + " where customer.searchId like :parentSearchId" + " and customer.office.officeId = :parentOfficeId";
Query update = this.genericDao.createQueryForUpdate(hql);
update.setParameter("parentLoanOfficer", parentLO);
update.setParameter("parentSearchId", parentSearchId + ".%");
update.setParameter("parentOfficeId", parentOfficeId);
update.executeUpdate();
updateLoanOfficersForAllChildrenAccounts(parentLO, parentSearchId, parentOfficeId);
}
use of org.hibernate.Query in project head by mifos.
the class LegacyPersonnelDao method getAllPersonnelNotes.
public QueryResult getAllPersonnelNotes(Short personnelId) throws PersistenceException {
QueryResult notesResult = null;
try {
Session session = null;
notesResult = QueryFactory.getQueryResult("NotesSearch");
session = StaticHibernateUtil.getSessionTL();
Query query = session.getNamedQuery(NamedQueryConstants.GETALLPERSONNELNOTES);
query.setInteger("PERSONNEL_ID", personnelId);
notesResult.executeQuery(query);
} catch (HibernateProcessException hpe) {
throw new PersistenceException(hpe);
} catch (HibernateSearchException hse) {
throw new PersistenceException(hse);
}
return notesResult;
}
Aggregations