use of org.mifos.framework.exceptions.ConnectionNotFoundException in project head by mifos.
the class LegacyGenericDao method execUniqueResultNamedQueryWithResultTransformer.
@SuppressWarnings("unchecked")
public <T extends Object> T execUniqueResultNamedQueryWithResultTransformer(final String queryName, final Map<String, ?> queryParameters, final Class<T> clazz) {
try {
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);
}
}
use of org.mifos.framework.exceptions.ConnectionNotFoundException in project head by mifos.
the class LegacyGenericDao method execUniqueResultNamedQueryWithoutFlush.
public Object execUniqueResultNamedQueryWithoutFlush(final String queryName, final Map<String, ?> queryParameters) throws PersistenceException {
try {
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);
}
}
use of org.mifos.framework.exceptions.ConnectionNotFoundException in project head by mifos.
the class LegacyGenericDao method execUniqueResultNamedQuery.
public Object execUniqueResultNamedQuery(final String queryName, final Map<String, ?> queryParameters) throws PersistenceException {
try {
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);
}
}
Aggregations