use of org.hibernate.Session in project head by mifos.
the class QueryResultSearchDTOImpl method get.
/**
* Returns the requested set of search result objects based on the pagination at the front end.
*/
@Override
public List<Object> get(int position, int noOfObjects) throws HibernateSearchException {
Session session = null;
List<Object> returnList = new ArrayList<Object>();
List<?> list = new ArrayList<Object>();
try {
session = StaticHibernateUtil.getSessionTL();
Query query = prepareQuery(session, queryInputs.getQueryStrings()[1]);
query.setFirstResult(position);
query.setMaxResults(noOfObjects);
list = query.list();
logger.debug("\n\nInside get of QueryResultSearchDTOImpl.java . size of main query=" + list.size());
this.queryInputs.setTypes(query.getReturnTypes());
dtoBuilder.setInputs(queryInputs);
returnList = new ArrayList<Object>();
for (int i = 0; i < list.size(); i++) {
if (buildDTO) {
returnList.add(buildDTO((Object[]) list.get(i)));
} else {
if (i < noOfObjects) {
returnList.add(list.get(i));
}
}
}
StaticHibernateUtil.closeSession();
} catch (Exception e) {
throw new HibernateSearchException(HibernateConstants.SEARCH_FAILED, e);
}
return returnList;
}
use of org.hibernate.Session in project head by mifos.
the class ApplicationInitializer method applyMifos4948Fix.
@SuppressWarnings("unchecked")
private void applyMifos4948Fix() throws AccountException {
Session session = StaticHibernateUtil.getSessionTL();
List<LoanBO> fixLoans;
Query query = session.getNamedQuery("fetchMissingInstalmentsForWriteOffsAndReschedules");
fixLoans = query.list();
if (fixLoans != null && fixLoans.size() > 0) {
for (LoanBO fixLoan : fixLoans) {
Set<AccountActionDateEntity> fixLoanSchedules = fixLoan.getAccountActionDates();
Money totalMissedPayment = new Money(fixLoan.getCurrency());
if (fixLoanSchedules != null && fixLoanSchedules.size() > 0) {
for (AccountActionDateEntity fixLoanSchedule : fixLoanSchedules) {
LoanScheduleEntity loanInstallment = (LoanScheduleEntity) fixLoanSchedule;
totalMissedPayment = totalMissedPayment.add(loanInstallment.getPrincipalDue());
}
}
logger.info("MIFOS-4948 - Loan: " + fixLoan.getGlobalAccountNum() + " - Adding payment: " + totalMissedPayment + " to fix instalments that should have been written-off or rescheduled.");
fixLoan.applyMifos4948FixPayment(totalMissedPayment);
}
logger.info(fixLoans.size() + " Account Payments created to fix data related to MIFOS-4948");
}
}
use of org.hibernate.Session in project head by mifos.
the class ProductCategoryBOIntegrationTest method deleteProductCategory.
private void deleteProductCategory(ProductCategoryBO productCategoryBO) {
Session session = StaticHibernateUtil.getSessionTL();
Transaction transaction = StaticHibernateUtil.startTransaction();
session.delete(productCategoryBO);
session.flush();
}
use of org.hibernate.Session in project head by mifos.
the class TestObjectFactory method deleteAccountWithoutFee.
private static void deleteAccountWithoutFee(final AccountBO account) {
Session session = StaticHibernateUtil.getSessionTL();
deleteAccountPayments(account);
deleteAccountActionDates(account, session);
deleteAccountFees(account);
deleteSpecificAccount(account, session);
}
use of org.hibernate.Session in project head by mifos.
the class TestObjectPersistence method update.
public void update(AbstractEntity obj) {
Session session = StaticHibernateUtil.getSessionTL();
StaticHibernateUtil.startTransaction();
session.saveOrUpdate(obj);
StaticHibernateUtil.flushSession();
}
Aggregations