builtQuery = composeHQLQuery(fullQuery, furtherClauses, lazyFetch);
}
if (builtQuery == null) {
throw new WGQueryException(query, "Unknown query type: " + type);
}
builtQuery = WGUtils.strReplace(builtQuery, "\"", "'", true);
if (params != null) {
params.put(WGDatabase.QUERYOPTION_RETURNQUERY, builtQuery);
}
List results = null;
try {
Query hibQuery = getSession().createQuery(builtQuery);
int maxResults = 0;
if (params.containsKey(WGDatabase.QUERYOPTION_MAXRESULTS)) {
maxResults = ((Number) params.get(WGDatabase.QUERYOPTION_MAXRESULTS)).intValue();
}
if (maxResults > 0) {
hibQuery.setMaxResults(maxResults);
}
HibernateResultSet.injectQueryParams(hibQuery, queryParams);
if (lazyFetch) {
if (languagesPriorityList != null) {
return new WGLanguageChoosingHQLResultSet(this, hibQuery, queryParams, languagesPriorityList);
}
else {
return new WGLazyHQLResultSet(this, hibQuery, queryParams);
}
}
else {
return new WGStraightHQLResultSet(this, hibQuery, queryParams);
}
}
catch (QueryException e) {
throw new WGQueryException(builtQuery, e.getMessage(), e);
}
catch (HibernateException e) {
throw new WGBackendException("Error executing HQL query", e);
}