|Group by statement is not rendered with criteria api [message #1015251]
||Wed, 27 February 2013 16:40
| Mathias Hauser
Registered: February 2013
The following code should return an orderd list of word entities. The problem here is that i use an aggregate function in the order section but this throws an error because the group by is not rendered.|
Generated sql = SELECT t1.ID AS a1, t1.CHANGED AS a2, t1.CREATED AS a3, t1.DELETED AS a4, t1.IGNORED AS a5, t1.TEXT AS a6 FROM FEEDENTRYWORD t0, WORD t1 WHERE ((LOWER(t1.TEXT) LIKE ? AND (t1.IGNORED = ?)) AND (t1.ID = t0.WORD_ID)) ORDER BY SUM(t0.OCCURRENCES) DESC LIMIT ? OFFSET ?
Do I something wrong here or is something wrong with eclipselink?
CriteriaQuery<Word> criteriaQuery = criteriaQuery(clazz);
Root<Word> root = root(criteriaQuery, clazz);
Root<FeedEntryWord> rootFeed = root(criteriaQuery, FeedEntryWord.class);
ignoredWhere(criteriaQuery, root, rootFeed, searchFields, searchText);
Query query = query(criteriaQuery);
setFirstMax(query, first, max);
List<Word> words = query.getResultList();