Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Group by statement is not rendered with criteria api
Group by statement is not rendered with criteria api [message #1015251] Wed, 27 February 2013 16:40 Go to previous message
Mathias Hauser is currently offline Mathias Hauser
Messages: 2
Registered: February 2013
Junior Member
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);
		criteriaQuery.select(root);
		ignoredWhere(criteriaQuery, root, rootFeed, searchFields, searchText);
		criteriaQuery.groupBy(root);
		criteriaQuery.orderBy(criteriaBuilder.desc(criteriaBuilder.sum(rootFeed.<Integer> get("occurrences"))));
		Query query = query(criteriaQuery);
		setFirstMax(query, first, max);
		List<Word> words = query.getResultList();
		printSQL(query);
		return words;
 
Read Message
Read Message
Read Message
Previous Topic:A non-read-only mapping must be defined for the sequence number field
Next Topic:Is here the way to regulate result of query to child tables of an entity.
Goto Forum:
  


Current Time: Fri May 24 23:32:57 EDT 2013

Powered by FUDForum. Page generated in 0.03684 seconds