Search in sources :

Example 91 with Session

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();
    }
}
Also used : Session(org.hibernate.Session)

Example 92 with Session

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();
    }
}
Also used : HibernateProcessException(org.mifos.framework.exceptions.HibernateProcessException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) HibernateException(org.hibernate.HibernateException) ReportException(org.mifos.reports.exceptions.ReportException) SystemException(org.mifos.framework.exceptions.SystemException) ReportException(org.mifos.reports.exceptions.ReportException) HibernateProcessException(org.mifos.framework.exceptions.HibernateProcessException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) HibernateException(org.hibernate.HibernateException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) Session(org.hibernate.Session)

Example 93 with Session

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();
    }
}
Also used : HibernateProcessException(org.mifos.framework.exceptions.HibernateProcessException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) HibernateException(org.hibernate.HibernateException) ReportException(org.mifos.reports.exceptions.ReportException) SystemException(org.mifos.framework.exceptions.SystemException) ReportException(org.mifos.reports.exceptions.ReportException) HibernateProcessException(org.mifos.framework.exceptions.HibernateProcessException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) HibernateException(org.hibernate.HibernateException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) Session(org.hibernate.Session)

Example 94 with Session

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();
    }
}
Also used : HibernateProcessException(org.mifos.framework.exceptions.HibernateProcessException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) HibernateException(org.hibernate.HibernateException) ReportException(org.mifos.reports.exceptions.ReportException) SystemException(org.mifos.framework.exceptions.SystemException) ReportException(org.mifos.reports.exceptions.ReportException) HibernateProcessException(org.mifos.framework.exceptions.HibernateProcessException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) HibernateException(org.hibernate.HibernateException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) Session(org.hibernate.Session)

Example 95 with Session

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;
}
Also used : Query(org.hibernate.Query) HibernateSearchException(org.mifos.framework.exceptions.HibernateSearchException) HibernateSearchException(org.mifos.framework.exceptions.HibernateSearchException) Session(org.hibernate.Session)

Aggregations

Session (org.hibernate.Session)4457 Test (org.junit.Test)2517 Transaction (org.hibernate.Transaction)1327 List (java.util.List)576 ArrayList (java.util.ArrayList)475 Test (org.testng.annotations.Test)411 TestForIssue (org.hibernate.testing.TestForIssue)389 Query (org.hibernate.Query)345 HibernateException (org.hibernate.HibernateException)299 DAOException (com.tomasio.projects.trainning.exception.DAOException)186 Criteria (org.hibernate.Criteria)174 Date (java.util.Date)134 Iterator (java.util.Iterator)127 SkipForDialect (org.hibernate.testing.SkipForDialect)114 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)113 SQLException (java.sql.SQLException)108 Map (java.util.Map)105 SessionFactory (org.hibernate.SessionFactory)105 GradingFactorDaoException (com.remswork.project.alice.dao.exception.GradingFactorDaoException)104 GradingFactorException (com.remswork.project.alice.exception.GradingFactorException)104