use of org.hibernate.Session in project head by mifos.
the class ReportsPersistence method createJasperMap.
public void createJasperMap(ReportsJasperMap map) {
Session session = null;
try {
session = StaticHibernateUtil.getSessionTL();
createJasperMap(session, map);
} finally {
StaticHibernateUtil.closeSession();
}
}
use of org.hibernate.Session in project head by mifos.
the class ReportsPersistence method deleteReportsParamsMap.
/**
* Deletes a link between report and a parameter
*/
public void deleteReportsParamsMap(ReportsParamsMapValue reportsParamsMapValue) throws ApplicationException, SystemException {
Session session = null;
try {
session = StaticHibernateUtil.getSessionTL();
StaticHibernateUtil.startTransaction();
session.delete(reportsParamsMapValue);
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 ReportsPersistence method deleteReportParams.
public void deleteReportParams(ReportsParamsValue reportsParams) throws ApplicationException, SystemException {
Session session = null;
try {
session = StaticHibernateUtil.getSessionTL();
StaticHibernateUtil.startTransaction();
session.delete(reportsParams);
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 ReportsPersistence method updateReportsJasperMap.
/**
* sets a link between report and a jasper file
*/
public void updateReportsJasperMap(ReportsJasperMap reportsJasperMap) throws ApplicationException, SystemException {
Session session = null;
try {
session = StaticHibernateUtil.getSessionTL();
StaticHibernateUtil.startTransaction();
session.update(reportsJasperMap);
session.flush();
StaticHibernateUtil.commitTransaction();
} catch (HibernateProcessException e) {
StaticHibernateUtil.rollbackTransaction();
throw new ApplicationException(e);
} 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 QueryResultAccountIdSearch method getSize.
//---Watch out for closeSession block as the cne commendted out here is no longer in codebase
/*
* public List accountIdSearch(String searchString,Short officeId) throws
* SystemException { this.searchString = searchString;
*
* try{ Session session=null; session= QuerySession.getSession(); Query
* query=null; if( officeId.shortValue()==0) {
* query=session.getNamedQuery(NamedQueryConstants
* .ACCOUNT_ID_SEARCH_NOOFFICEID);
* query.setString("SEARCH_STRING",searchString); } else {
*
* query=session.getNamedQuery(NamedQueryConstants.ACCOUNT_ID_SEARCH);
* query.setString("SEARCH_STRING",searchString);
* query.setShort("OFFICEID",officeId); }
*
*
* list=query.list(); this.queryInputs.setTypes(query.getReturnTypes());
* dtoBuilder.setInputs(queryInputs); QuerySession.closeSession(session); }
* catch(HibernateProcessException hpe) { throw new SystemException(); }
* return list; }
*/
@Override
public int getSize() throws HibernateSearchException {
try {
Session session = StaticHibernateUtil.getSessionTL();
if (this.queryInputs == null) {
throw new HibernateSearchException(HibernateConstants.SEARCH_INPUTNULL);
}
Query query = prepareQuery(session, queryInputs.getQueryStrings()[0]);
Integer resultSetCount = ((Number) query.uniqueResult()).intValue();
this.queryInputs.setTypes(query.getReturnTypes());
dtoBuilder.setInputs(queryInputs);
if (resultSetCount != null && resultSetCount > 0) {
size = resultSetCount;
}
StaticHibernateUtil.closeSession();
} catch (Exception e) {
throw new HibernateSearchException(HibernateConstants.SEARCH_FAILED, e);
}
return size;
}
Aggregations