Search in sources :

Example 21 with Query

use of org.hibernate.Query in project head by mifos.

the class FinancialInitializer method cacheCOA.

/**
     * Reads chart of accounts from the database and caches in memory.
     */
@SuppressWarnings("unchecked")
public static void cacheCOA() {
    if (ChartOfAccountsCache.isInitialized()) {
        return;
    }
    Session session = StaticHibernateUtil.getSessionTL();
    Query query = session.getNamedQuery(NamedQueryConstants.GET_ALL_COA);
    List<COABO> coaBoList = query.list();
    for (COABO coabo : coaBoList) {
        ChartOfAccountsCache.add(hibernateInitalize(coabo));
    }
}
Also used : Query(org.hibernate.Query) COABO(org.mifos.accounts.financial.business.COABO) Session(org.hibernate.Session)

Example 22 with Query

use of org.hibernate.Query in project head by mifos.

the class ImportTransactionsServiceFacadeWebTier method validateForAdjustedPayments.

private void validateForAdjustedPayments(AccountTrxnEntity trxn, TreeSet<String> accountsWithAdjustedPayments) {
    if (accountsWithAdjustedPayments.contains(trxn.getAccount().getGlobalAccountNum())) {
        throw new BusinessRuleException("errors.paymentsWereAdjusted");
    }
    Query query = StaticHibernateUtil.getSessionTL().getNamedQuery("countRelatedTransactions");
    query.setParameter("trxn_id", trxn.getAccountTrxnId().intValue());
    if (((BigInteger) query.uniqueResult()).intValue() > 0) {
        accountsWithAdjustedPayments.add(trxn.getAccount().getGlobalAccountNum());
        throw new BusinessRuleException("errors.paymentsWereAdjusted");
    }
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) Query(org.hibernate.Query)

Example 23 with Query

use of org.hibernate.Query in project head by mifos.

the class AccountingDaoHibernate method findLastProcessingUpdatedDate.

@Override
public String findLastProcessingUpdatedDate(String namedQueryString, String globalOfficeNumber) {
    String lastProcessingDate = null;
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy");
    Query query = createdNamedQuery(namedQueryString);
    query.setString("GLOBAL_OFFICE_NUMBER", globalOfficeNumber);
    List<ProcessUpdateBo> list = query.list();
    if (list.size() == 0) {
        Query q = createdNamedQuery("getConfigurationKeyValueByKey");
        q.setString("KEY", "MisProcessing");
        List<ConfigurationKeyValue> value = q.list();
        if (value.size() > 0) {
            ConfigurationKeyValue configurationKeyValue = value.get(0);
            lastProcessingDate = configurationKeyValue.getValue();
        }
    } else if (list.size() > 0 && !"".equals(list.get(0).getLastUpdateDate())) {
        ProcessUpdateBo processUpdateBo = list.get(0);
        if (processUpdateBo.getLastUpdateDate() != null) {
            lastProcessingDate = simpleDateFormat.format(processUpdateBo.getLastUpdateDate());
        }
    }
    return lastProcessingDate;
}
Also used : Query(org.hibernate.Query) ProcessUpdateBo(org.mifos.application.accounting.business.ProcessUpdateBo) ConfigurationKeyValue(org.mifos.config.business.ConfigurationKeyValue) SimpleDateFormat(java.text.SimpleDateFormat)

Example 24 with Query

use of org.hibernate.Query in project head by mifos.

the class AccountingDaoHibernate method findLastProcessingDate.

@Override
public String findLastProcessingDate(String namedQueryString) {
    String lastProcessingDate = null;
    Query query = createdNamedQuery(namedQueryString);
    query.setString("KEY", "MisProcessing");
    List<ConfigurationKeyValue> list = query.list();
    if (list.size() > 0 && !"".equals(list.get(0).getValue())) {
        ConfigurationKeyValue configurationKeyValue = list.get(0);
        lastProcessingDate = configurationKeyValue.getValue();
    }
    return lastProcessingDate;
}
Also used : Query(org.hibernate.Query) ConfigurationKeyValue(org.mifos.config.business.ConfigurationKeyValue)

Example 25 with Query

use of org.hibernate.Query in project head by mifos.

the class AccountingDaoHibernate method findFinancialYear.

@Override
public List<FinancialYearBO> findFinancialYear() {
    Query query = createdNamedQuery("getStartDateByStatus");
    List<FinancialYearBO> list = query.list();
    return list;
}
Also used : Query(org.hibernate.Query) FinancialYearBO(org.mifos.application.accounting.business.FinancialYearBO)

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