List of usage examples for org.hibernate Query setProperties
Query<R> setProperties(Map bean);
From source file:org.mifos.framework.persistence.LegacyGenericDao.java
License:Open Source License
public Object execUniqueResultNamedQuery(final String queryName, final Map<String, ?> queryParameters) throws PersistenceException { try {// w w w. j a v a 2 s . c o m Query query = getSession().getNamedQuery(queryName); logger.debug("The query object for the query with the name " + queryName + " has been obtained"); query.setProperties(queryParameters); return query.uniqueResult(); } catch (GenericJDBCException gje) { throw new ConnectionNotFoundException(gje); } catch (Exception e) { throw new PersistenceException(e); } }
From source file:org.mifos.framework.persistence.LegacyGenericDao.java
License:Open Source License
public Object execUniqueResultNamedQueryWithoutFlush(final String queryName, final Map<String, ?> queryParameters) throws PersistenceException { try {//from ww w. j a v a2s.c om Session sess = getSession(); sess.setFlushMode(FlushMode.MANUAL); Query query = getSession().getNamedQuery(queryName); logger.debug("The query object for the query with the name " + queryName + " has been obtained"); query.setProperties(queryParameters); Object returnObject = query.uniqueResult(); sess.setFlushMode(FlushMode.AUTO); return returnObject; } catch (GenericJDBCException gje) { throw new ConnectionNotFoundException(gje); } catch (Exception e) { throw new PersistenceException(e); } }
From source file:org.mifos.framework.persistence.LegacyGenericDao.java
License:Open Source License
@SuppressWarnings("unchecked") public <T extends Object> T execUniqueResultNamedQueryWithResultTransformer(final String queryName, final Map<String, ?> queryParameters, final Class<T> clazz) { try {// ww w.j a va 2 s. c o m Query query = getSession().getNamedQuery(queryName) .setResultTransformer(Transformers.aliasToBean(clazz)); query.setProperties(queryParameters); query.setResultTransformer(Transformers.aliasToBean(clazz)); return (T) query.uniqueResult(); } catch (GenericJDBCException gje) { throw new ConnectionNotFoundException(gje); } catch (Exception e) { throw new MifosRuntimeException(e); } }
From source file:org.mifos.framework.persistence.LegacyGenericDao.java
License:Open Source License
@SuppressWarnings("unchecked") public <T extends Object> List<T> executeNamedQueryWithResultTransformer(final String queryName, final Map<String, ?> queryParameters, final Class<T> clazz) { try {//from w w w .ja v a 2s .co m Query query = getSession().getNamedQuery(queryName); query.setResultTransformer(Transformers.aliasToBean(clazz)); query.setProperties(queryParameters); return query.list(); } catch (Exception e) { throw new MifosRuntimeException(e); } }
From source file:org.mifos.framework.persistence.LegacyGenericDao.java
License:Open Source License
public int executeNamedQueryForUpdate(final String queryName, final Map<String, ?> queryParameters) throws PersistenceException { try {/*from w ww.j a va 2s. c o m*/ StaticHibernateUtil.startTransaction(); Query query = createdNamedQuery(queryName); System.out.println(query.getQueryString()); query.setProperties(queryParameters); int result = query.executeUpdate(); StaticHibernateUtil.commitTransaction(); return result; } catch (Exception e) { throw new PersistenceException(e); } }
From source file:org.mifos.reports.branchreport.persistence.BranchReportSqlPersistence.java
License:Open Source License
public Integer getActiveBorrowersCount(Short officeId, CustomerLevel customerLevel) { Query query = createdNamedQuery(NamedQueryConstants.GET_SQL_ACTIVE_ACCOUNT_USER_COUNT_FOR_OFFICE); query.setParameterList("accountStateIds", Arrays.asList(AccountState.LOAN_ACTIVE_IN_BAD_STANDING.getValue(), AccountState.LOAN_ACTIVE_IN_GOOD_STANDING.getValue())); Map<String, Object> params = populateParamsForActiveClientAccountSummary(officeId, customerLevel, AccountTypes.LOAN_ACCOUNT);//from w ww . j a v a2 s . c o m query.setProperties(params); return getCountFromQueryResult(query.list()); }
From source file:org.mifos.reports.branchreport.persistence.BranchReportSqlPersistence.java
License:Open Source License
public Integer getVeryPoorActiveBorrowersCount(Short officeId, CustomerLevel customerLevel) { Query query = createdNamedQuery(NamedQueryConstants.GET_SQL_VERY_POOR_ACTIVE_ACCOUNT_USER_COUNT_FOR_OFFICE); query.setParameterList("accountStateIds", Arrays.asList(AccountState.LOAN_ACTIVE_IN_BAD_STANDING.getValue(), AccountState.LOAN_ACTIVE_IN_GOOD_STANDING.getValue())); Map<String, Object> params = populateParamsForActiveClientAccountSummary(officeId, customerLevel, AccountTypes.LOAN_ACCOUNT);//from ww w. j a v a 2 s. c o m query.setProperties(params); return getCountFromQueryResult(query.list()); }
From source file:org.mifos.reports.branchreport.persistence.BranchReportSqlPersistence.java
License:Open Source License
public Integer getActiveSaversCount(Short officeId, CustomerLevel customerLevel) { Map<String, Object> params = populateParamsForActiveClientAccountSummary(officeId, customerLevel, AccountTypes.SAVINGS_ACCOUNT); Query query = createdNamedQuery(NamedQueryConstants.GET_SQL_ACTIVE_ACCOUNT_USER_COUNT_FOR_OFFICE); query.setParameterList("accountStateIds", Arrays.asList(AccountState.SAVINGS_ACTIVE.getValue(), AccountState.SAVINGS_INACTIVE.getValue())); query.setProperties(params); return getCountFromQueryResult(query.list()); }
From source file:org.mifos.reports.branchreport.persistence.BranchReportSqlPersistence.java
License:Open Source License
public Integer getVeryPoorActiveSaversCount(Short officeId, CustomerLevel customerLevel) { Map<String, Object> params = populateParamsForActiveClientAccountSummary(officeId, customerLevel, AccountTypes.SAVINGS_ACCOUNT); Query query = createdNamedQuery(NamedQueryConstants.GET_SQL_VERY_POOR_ACTIVE_ACCOUNT_USER_COUNT_FOR_OFFICE); query.setParameterList("accountStateIds", Arrays.asList(AccountState.SAVINGS_ACTIVE.getValue(), AccountState.SAVINGS_INACTIVE.getValue())); query.setProperties(params); return getCountFromQueryResult(query.list()); }
From source file:org.mifos.reports.branchreport.persistence.BranchReportSqlPersistence.java
License:Open Source License
private Query createQueryForCustomerCountBasedOnStatus(String queryName, Short officeId, CustomerLevel customerLevel, List<String> customerStatusDescriptions) { Query query = createdNamedQuery(queryName); query.setParameterList(CUSTOMER_STATUS_DESCRIPTION, customerStatusDescriptions); query.setProperties(populateQueryParams(officeId, customerLevel)); return query; }