use of org.hibernate.Session in project head by mifos.
the class BranchReportHelper method execute.
@Override
public void execute(long timeInMillis) throws BatchJobException {
Session session = StaticHibernateUtil.getSessionTL();
StaticHibernateUtil.startTransaction();
Date runDate = new Date(timeInMillis);
try {
removeExistingBranchReportsForGivenRunDate(runDate);
populateBranchReportBatch(session, runDate);
StaticHibernateUtil.commitTransaction();
} catch (HibernateException e) {
StaticHibernateUtil.rollbackTransaction();
throw new BatchJobException(e);
} catch (ServiceException e) {
throw new BatchJobException(e);
}
}
use of org.hibernate.Session in project head by mifos.
the class FinancialInitializer method initalizeFinancialAction.
@SuppressWarnings("unchecked")
public static void initalizeFinancialAction() throws FinancialException {
Session session = StaticHibernateUtil.getSessionTL();
try {
Query queryFinancialAction = session.getNamedQuery(FinancialQueryConstants.GET_ALL_FINANCIAL_ACTION);
List<FinancialActionTypeEntity> listFinancialAction = queryFinancialAction.list();
for (FinancialActionTypeEntity fabo : listFinancialAction) {
FinancialActionCache.addToCache(fabo);
}
} catch (Exception e) {
throw new FinancialException(FinancialExceptionConstants.FINANCIALACTION_INITFAILED, e);
}
}
use of org.hibernate.Session in project head by mifos.
the class FinancialInitializer method cacheCOA.
/**
* Reads chart of accounts from the database and caches in memory.
*/
@SuppressWarnings("unchecked")
public static void cacheCOA() {
if (ChartOfAccountsCache.isInitialized()) {
return;
}
Session session = StaticHibernateUtil.getSessionTL();
Query query = session.getNamedQuery(NamedQueryConstants.GET_ALL_COA);
List<COABO> coaBoList = query.list();
for (COABO coabo : coaBoList) {
ChartOfAccountsCache.add(hibernateInitalize(coabo));
}
}
use of org.hibernate.Session in project head by mifos.
the class FeeDaoHibernate method doFetchListOfMasterDataFor.
@SuppressWarnings("unchecked")
private <T extends MasterDataEntity> List<T> doFetchListOfMasterDataFor(Class<T> type) {
Session session = StaticHibernateUtil.getSessionTL();
List<T> masterEntities = session.createQuery("from " + type.getName()).list();
for (MasterDataEntity masterData : masterEntities) {
Hibernate.initialize(masterData.getNames());
}
return masterEntities;
}
use of org.hibernate.Session 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);
}
}
Aggregations