use of org.hibernate.Session 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.hibernate.Session 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.hibernate.Session in project head by mifos.
the class ReportsPersistence method createReportsDataSource.
public void createReportsDataSource(ReportsDataSource reportsDataSource) throws ApplicationException, SystemException {
Session session = null;
try {
session = StaticHibernateUtil.getSessionTL();
StaticHibernateUtil.startTransaction();
session.save(reportsDataSource);
session.flush();
StaticHibernateUtil.commitTransaction();
} catch (HibernateProcessException hpe) {
StaticHibernateUtil.rollbackTransaction();
throw new ApplicationException(hpe);
} catch (HibernateException e) {
StaticHibernateUtil.rollbackTransaction();
throw new ReportException(ReportsConstants.CREATE_FAILED_EXCEPTION, e);
} catch (Exception e) {
StaticHibernateUtil.rollbackTransaction();
throw new ReportException(ReportsConstants.CREATE_FAILED_EXCEPTION, e);
} finally {
StaticHibernateUtil.closeSession();
}
}
use of org.hibernate.Session in project head by mifos.
the class EntityMasterData method init.
/**
* This method creates a map of entity master table as sets it into the
* servletcontext so that it is available till the application is up.
*
* @throws HibernateProcessException
*/
public void init() throws HibernateProcessException {
Session session = null;
try {
session = StaticHibernateUtil.getSessionTL();
Query query = session.getNamedQuery(NamedQueryConstants.GET_ENTITY_MASTER);
List<EntityMaster> entityMasterData = query.list();
for (EntityMaster entityMaster : entityMasterData) {
entityMap.put(entityMaster.getEntityType(), entityMaster.getId());
}
} catch (HibernateException e) {
logger.error("table entity_master could not be fetched", e);
}
}
use of org.hibernate.Session in project head by mifos.
the class ReportsPersistence method getReport.
public ReportsBO getReport(Short reportId) {
Session session = null;
session = StaticHibernateUtil.getSessionTL();
return (ReportsBO) session.load(ReportsBO.class, reportId);
}
Aggregations