Search in sources :

Example 81 with Session

use of org.hibernate.Session in project head by mifos.

the class GenericDaoHibernate method executeUniqueResultNamedQueryWithResultTransformer.

@Override
public final Object executeUniqueResultNamedQueryWithResultTransformer(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.uniqueResult();
    } catch (Exception e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : Query(org.hibernate.Query) MifosRuntimeException(org.mifos.core.MifosRuntimeException) Session(org.hibernate.Session) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 82 with Session

use of org.hibernate.Session in project head by mifos.

the class GenericDaoHibernate method executeNamedQuery.

@SuppressWarnings("unchecked")
@Override
public final List<? extends Object> executeNamedQuery(final String queryName, final Map<String, ?> queryParameters) {
    try {
        Session session = getSession();
        Query query = session.getNamedQuery(queryName);
        query.setProperties(queryParameters);
        return query.list();
    } catch (Exception e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : Query(org.hibernate.Query) MifosRuntimeException(org.mifos.core.MifosRuntimeException) Session(org.hibernate.Session) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 83 with Session

use of org.hibernate.Session in project head by mifos.

the class GenericDaoHibernate method executeUniqueResultNamedQuery.

@Override
public final Object executeUniqueResultNamedQuery(final String queryName, final Map<String, ?> queryParameters) {
    try {
        Session session = getSession();
        Query query = session.getNamedQuery(queryName);
        query.setProperties(queryParameters);
        return query.uniqueResult();
    } catch (Exception e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : Query(org.hibernate.Query) MifosRuntimeException(org.mifos.core.MifosRuntimeException) Session(org.hibernate.Session) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 84 with Session

use of org.hibernate.Session 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);
    }
}
Also used : Query(org.hibernate.Query) MifosRuntimeException(org.mifos.core.MifosRuntimeException) Session(org.hibernate.Session) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 85 with Session

use of org.hibernate.Session 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);
    }
}
Also used : Query(org.hibernate.Query) MifosRuntimeException(org.mifos.core.MifosRuntimeException) Session(org.hibernate.Session) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

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