Aggregate functions in Hibernate by R4R Team

The supported aggregate functions are:

avg(...), sum(...), min(...), max(...) count(*)
count(...), count(distinct ...), count(all...)

We can see that HQL queries can even return the results of aggregate functions on properties:

Example for this we can take:

select avg(student.weight), sum(student.weight), max(student.weight), count(student)
from Student student

we can use arithmetic operators, concatenation, and recognized SQL functions in the select clause:

    select cat.weight + sum(kitten.weight) from Student student join student.kittens kitten
    group by cat.id, student.weight

    select firstName||' '||initial||' '||upper(lastName) from Person

The distinct and all keywords can be used and have the same semantics as in SQL.

select distinct cat.name from Student student

select count(distinct student.name), count(cat) from Student student
Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!