While looking at https://github.com/rhq-project/rhq/pull/2 I got failed executions of the rest-tests because of Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: ORDER near line 4, column 1 [SELECT alert FROM org.rhq.core.domain.alert.Alert alert WHERE ORDER BY alert.ctime DESC, alert.id ASC ] Here the WHERE clause is empty. Looking at the code reveals that we do some incomplete checking here This is the code in question org/rhq/enterprise/server/util/CriteriaQueryGenerator.java:550 Map<String, Object> filterFields = getFilterFields(criteria); if (filterFields.size() > 0 || authorizationPermsFragment != null || authorizationCustomConditionFragment != null || searchExpressionWhereClause != null) { results.append("WHERE "); <<<<----------- (1) } String conjunctiveFragment = criteria.isFiltersOptional() ? "OR " : "AND "; boolean wantCaseInsensitiveMatch = !criteria.isCaseSensitive(); // criteria StringBuilder conjunctiveResults = new StringBuilder(); boolean firstCrit = true; for (Map.Entry<String, Object> filterField : filterFields.entrySet()) { Object filterFieldValue = filterField.getValue(); // if this filter field is non-binding (that is, the query has no parameter whose value is to be bound for the field) // and that filter field is turned off, do nothing and continue to the next filter. // this in effect does not filter on this field at all. if (Criteria.NonBindingOverrideFilter.OFF.equals(filterFieldValue)) { continue; <<<<<<<<<<<<<---- (2) } At 1) we check if the filterList is not empty and put a 'WHERE' in then at 2) if the filter is 'OFF', we do not put it in the WHERE clause. If that was the only filter statement in the list, we are left with a WHERE keyword without a clause.
Created attachment 879069 [details] Possible patch
Merged by Lukas from https://github.com/rhq-project/rhq/pull/17
Bulk closing of RHQ 4.11 issues, now that RHQ 4.12 is out. If you find an issue with those, please open a new BZ, linking to the old one.