Search in sources :

Example 26 with Query

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

the class AccountingDaoHibernate method findExistedGlBalacesBOs.

public List<GlBalancesBO> findExistedGlBalacesBOs(Integer officeLevelId, String officeId, String glCodeValue, Integer financialYearId) {
    List<GlBalancesBO> balancesBOs = null;
    Query query = createdNamedQuery("getExistedGlBalancesBO");
    query.setInteger("OFFICE_LEVEL", officeLevelId);
    query.setString("OFFICE_ID", officeId);
    query.setString("GLCODEVALUE", glCodeValue);
    query.setInteger("FINANCIALYEARID", financialYearId);
    balancesBOs = query.list();
    return balancesBOs;
}
Also used : Query(org.hibernate.Query) GlBalancesBO(org.mifos.application.accounting.business.GlBalancesBO)

Example 27 with Query

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

Example 28 with Query

use of org.hibernate.Query 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 29 with Query

use of org.hibernate.Query 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 30 with Query

use of org.hibernate.Query 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)

Aggregations

Query (org.hibernate.Query)481 Session (org.hibernate.Session)223 Test (org.junit.Test)184 List (java.util.List)85 Transaction (org.hibernate.Transaction)80 ArrayList (java.util.ArrayList)52 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)31 TestForIssue (org.hibernate.testing.TestForIssue)28 SQLQuery (org.hibernate.SQLQuery)27 MifosRuntimeException (org.mifos.core.MifosRuntimeException)24 PersistenceException (org.mifos.framework.exceptions.PersistenceException)22 HibernateException (org.hibernate.HibernateException)19 Collection (java.util.Collection)14 Date (java.util.Date)14 HashMap (java.util.HashMap)12 Iterator (java.util.Iterator)12 BigDecimal (java.math.BigDecimal)11 Map (java.util.Map)11 HibernateSearchException (org.mifos.framework.exceptions.HibernateSearchException)11 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)10