Search in sources :

Example 66 with MifosRuntimeException

use of org.mifos.core.MifosRuntimeException in project head by mifos.

the class GenericDaoHibernate method executeNamedQueryIterator.

@SuppressWarnings("unchecked")
@Override
public final Iterator<? extends Object> executeNamedQueryIterator(final String queryName, final Map<String, ?> queryParameters) {
    try {
        Session session = getSession();
        Query query = session.getNamedQuery(queryName);
        query.setProperties(queryParameters);
        return query.iterate();
    } catch (Exception e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : Query(org.hibernate.Query) MifosRuntimeException(org.mifos.core.MifosRuntimeException) Session(org.hibernate.Session) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 67 with MifosRuntimeException

use of org.mifos.core.MifosRuntimeException in project head by mifos.

the class GenericDaoHibernate method executeNamedQueryDelete.

@SuppressWarnings("unchecked")
@Override
public final int executeNamedQueryDelete(final String queryName, final Map<String, ?> queryParameters) {
    try {
        Session session = getSession();
        Query query = session.getNamedQuery(queryName);
        query.setProperties(queryParameters);
        return query.executeUpdate();
    } catch (Exception e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : Query(org.hibernate.Query) MifosRuntimeException(org.mifos.core.MifosRuntimeException) Session(org.hibernate.Session) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 68 with MifosRuntimeException

use of org.mifos.core.MifosRuntimeException in project head by mifos.

the class GenericDaoHibernate method update.

@Override
public final void update(final Object entity) {
    try {
        Session session = getSession();
        session.update(entity);
        AuditInterceptor interceptor = (AuditInterceptor) StaticHibernateUtil.getInterceptor();
        if (interceptor.isAuditLogRequired()) {
            interceptor.createChangeValueMap(entity);
        }
    } catch (Exception e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : AuditInterceptor(org.mifos.framework.components.audit.util.helpers.AuditInterceptor) MifosRuntimeException(org.mifos.core.MifosRuntimeException) Session(org.hibernate.Session) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 69 with MifosRuntimeException

use of org.mifos.core.MifosRuntimeException in project head by mifos.

the class GenericDaoHibernate method executeNamedQueryWithOffsetAndOrderAppend.

@SuppressWarnings("unchecked")
@Override
public final List<? extends Object> executeNamedQueryWithOffsetAndOrderAppend(final String queryName, final Map<String, ?> queryParameters, int position, int noOfObjects) {
    try {
        Session session = getSession();
        StringBuilder stringBuilder = new StringBuilder(session.getNamedQuery(queryName).getQueryString());
        stringBuilder.append(" ORDER BY ");
        stringBuilder.append(queryParameters.get("ordering"));
        Query query = session.createQuery(stringBuilder.toString());
        query.setProperties(queryParameters);
        query.setFirstResult(position);
        query.setMaxResults(noOfObjects);
        return query.list();
    } catch (Exception e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : Query(org.hibernate.Query) MifosRuntimeException(org.mifos.core.MifosRuntimeException) Session(org.hibernate.Session) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 70 with MifosRuntimeException

use of org.mifos.core.MifosRuntimeException in project head by mifos.

the class AccountingDaoHibernate method updateLastProcessDate.

public void updateLastProcessDate(Date lastProcessDate) {
    Query q = createdNamedQuery("getConfigurationKeyValueByKey");
    q.setString("KEY", "MisProcessing");
    List<ConfigurationKeyValue> list = q.list();
    if (list.size() > 0) {
        ConfigurationKeyValue configurationKeyValue = list.get(0);
        configurationKeyValue.setValue(DateUtils.format(lastProcessDate));
        try {
            createOrUpdate(configurationKeyValue);
        } catch (PersistenceException e) {
            throw new MifosRuntimeException(e);
        }
    }
}
Also used : Query(org.hibernate.Query) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ConfigurationKeyValue(org.mifos.config.business.ConfigurationKeyValue) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

MifosRuntimeException (org.mifos.core.MifosRuntimeException)305 PersistenceException (org.mifos.framework.exceptions.PersistenceException)136 ArrayList (java.util.ArrayList)102 BusinessRuleException (org.mifos.service.BusinessRuleException)95 UserContext (org.mifos.security.util.UserContext)94 MifosUser (org.mifos.security.MifosUser)87 AccountException (org.mifos.accounts.exceptions.AccountException)79 ServiceException (org.mifos.framework.exceptions.ServiceException)69 ApplicationException (org.mifos.framework.exceptions.ApplicationException)48 LoanBO (org.mifos.accounts.loan.business.LoanBO)41 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)39 UserContextFactory (org.mifos.accounts.servicefacade.UserContextFactory)37 MeetingException (org.mifos.application.meeting.exceptions.MeetingException)36 LocalDate (org.joda.time.LocalDate)35 CustomerBO (org.mifos.customers.business.CustomerBO)29 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)28 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)27 CustomerException (org.mifos.customers.exceptions.CustomerException)27 Money (org.mifos.framework.util.helpers.Money)27 AccountBO (org.mifos.accounts.business.AccountBO)25