use of org.mifos.core.MifosRuntimeException in project head by mifos.
the class CollectionSheetDaoHibernate method findAmountDueWhenInterestIsDueAtDibursementTime.
private Double findAmountDueWhenInterestIsDueAtDibursementTime(final Integer accountId) {
final Map<String, Object> queryParameters = new HashMap<String, Object>();
queryParameters.put("ACCOUNT_ID", accountId);
try {
final Object[] loanScheduleData = (Object[]) execUniqueResultNamedQuery("findFirstLoanSchedule", queryParameters);
final Integer loanScheduleId = Integer.valueOf(loanScheduleData[0].toString());
final Double firstScheduledPaymentAmount = calculateAmountDueFromLoanScheduleFields(loanScheduleData);
final Map<String, Object> feeQueryParameters = new HashMap<String, Object>();
queryParameters.put("LOAN_SCHEDULE_ID", loanScheduleId);
final Object[] loanScheduleFee = (Object[]) execUniqueResultNamedQuery("findLoanFeeSchedulesForALoanSchedule", feeQueryParameters);
final Double feesDueOnLoanSchedule = calculateFeesDueOnLoanSchedule(loanScheduleFee);
return firstScheduledPaymentAmount.doubleValue() + feesDueOnLoanSchedule.doubleValue();
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.core.MifosRuntimeException in project head by mifos.
the class GenericDaoHibernate method executeNamedQueryWithResultTransformer.
@SuppressWarnings("unchecked")
@Override
public final List<? extends Object> executeNamedQueryWithResultTransformer(final String queryName, final Map<String, ?> nameQueryParameters, final Class<?> className) {
try {
Session session = getSession();
Query query = session.getNamedQuery(queryName).setResultTransformer(Transformers.aliasToBean(className));
query.setProperties(nameQueryParameters);
return query.list();
} catch (Exception e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.core.MifosRuntimeException in project head by mifos.
the class GenericDaoHibernate method executeUniqueResultNamedQueryWithResultTransformer.
@Override
public final Object executeUniqueResultNamedQueryWithResultTransformer(final String queryName, final Map<String, ?> nameQueryParameters, final Class<?> className) {
try {
Session session = getSession();
Query query = session.getNamedQuery(queryName).setResultTransformer(Transformers.aliasToBean(className));
query.setProperties(nameQueryParameters);
return query.uniqueResult();
} catch (Exception e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.core.MifosRuntimeException in project head by mifos.
the class GenericDaoHibernate method executeNamedQuery.
@SuppressWarnings("unchecked")
@Override
public final List<? extends Object> executeNamedQuery(final String queryName, final Map<String, ?> queryParameters) {
try {
Session session = getSession();
Query query = session.getNamedQuery(queryName);
query.setProperties(queryParameters);
return query.list();
} catch (Exception e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.core.MifosRuntimeException in project head by mifos.
the class GenericDaoHibernate method executeUniqueResultNamedQuery.
@Override
public final Object executeUniqueResultNamedQuery(final String queryName, final Map<String, ?> queryParameters) {
try {
Session session = getSession();
Query query = session.getNamedQuery(queryName);
query.setProperties(queryParameters);
return query.uniqueResult();
} catch (Exception e) {
throw new MifosRuntimeException(e);
}
}
Aggregations