Javatpoint Logo
Javatpoint Logo

JPA Criteria GROUP BY Clause

The GROUP BY clause is used to collect data from one or more tables and arrange them in a group. In Criteria API, the groupBy() method of AbstractQuery interface is used to filter the records and group them.

Criteria GROUP BY Example

Here, we will perform GROUP BY operations on student table. Let us assume the table contains the following records: -

JPA Criteria GROUP BY Clause

Now, follow the below steps to perform operations: -

  • Create an entity class names as under com.javatpoint.jpa package. This class contains three attributes s_id, s_name and s_age with all the required annotations.

  • Now, map the entity class and other databases confiuguration in Persistence.xml file.


  • Once, we created the basic entity class and mapped the configuration into persistence.xml file, we can perform the different types of GROUP BY operation. Here, we are grouping the number of students on the basis of age.


JPA Criteria GROUP BY Clause

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA