Beginner |
|
Joined: Fri Aug 24, 2007 9:47 am Posts: 21
|
You need to use projections to do this because there is no explicit "group by" necessary in a criteria query. Certain projection types are defined to be grouping projections, which also appear in the SQL group by clause.
An alias can be assigned to a projection so that the projected value can be referred to in restrictions or orderings.
Here are two different ways to do this:
List results = session.createCriteria(Cat.class) .setProjection( Projections.groupProperty("color").as("colr") ) .addOrder( Order.asc("colr") ) .list();
_________________ recherche-programmeur.fr
|
|