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