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));
}
}
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");
}
}
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;
}
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;
}
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;
}
Aggregations