Search in sources :

Example 11 with Query

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);
    }
}
Also used : Query(org.hibernate.Query) PersistenceException(org.mifos.framework.exceptions.PersistenceException) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) HibernateException(org.hibernate.HibernateException) Session(org.hibernate.Session)

Example 12 with Query

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;
}
Also used : Query(org.hibernate.Query) CustomValueDto(org.mifos.application.master.business.CustomValueDto) Session(org.hibernate.Session) Transactional(org.mifos.framework.hibernate.helper.Transactional)

Example 13 with Query

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;
}
Also used : Query(org.hibernate.Query) CustomValueListElementDto(org.mifos.application.master.business.CustomValueListElementDto)

Example 14 with Query

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);
}
Also used : Query(org.hibernate.Query)

Example 15 with Query

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;
}
Also used : QueryResult(org.mifos.framework.hibernate.helper.QueryResult) HibernateProcessException(org.mifos.framework.exceptions.HibernateProcessException) Query(org.hibernate.Query) HibernateSearchException(org.mifos.framework.exceptions.HibernateSearchException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) Session(org.hibernate.Session)

Aggregations

Query (org.hibernate.Query)481 Session (org.hibernate.Session)223 Test (org.junit.Test)184 List (java.util.List)85 Transaction (org.hibernate.Transaction)80 ArrayList (java.util.ArrayList)52 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)31 TestForIssue (org.hibernate.testing.TestForIssue)28 SQLQuery (org.hibernate.SQLQuery)27 MifosRuntimeException (org.mifos.core.MifosRuntimeException)24 PersistenceException (org.mifos.framework.exceptions.PersistenceException)22 HibernateException (org.hibernate.HibernateException)19 Collection (java.util.Collection)14 Date (java.util.Date)14 HashMap (java.util.HashMap)12 Iterator (java.util.Iterator)12 BigDecimal (java.math.BigDecimal)11 Map (java.util.Map)11 HibernateSearchException (org.mifos.framework.exceptions.HibernateSearchException)11 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)10