Hibernate Criteria Grouping Example

Ads

In this tutorial you will learn about the Hibernate Criteria Projection Grouping.

Hibernate Criteria Grouping Example

In this tutorial you will learn about the Hibernate Criteria Projection
Grouping.

As we were using a 'group by' clause explicitly in HQL for grouping, there is
no need to use this clause in Criteria query. In Criteria query for grouping
projections certain types of projection are defined.

In the example given below I have used the Projections.groupProperty() for
grouping the projections. We may use Property.forName() besides the built-in
Projections with the setProjection() method. You can specify the number of
columns by using the Projections.projectionList().add(Projections.property()).