section we will show you, how to use the Count Query. Hibernate supports
multiple aggregate functions. when they are used in HQL queries, they return an
aggregate value (such as sum, average, and count) calculated from property
values of all objects satisfying other query criteria. These functions can be
used along with the distinct and all options, to return aggregate
values calculated from only distinct values and
count(*) (equivalent to count(all ...), counts null values also)
sum ( [ distinct | all ] object.property)
avg( [ distinct | all ] object.property)
max( [ distinct | all ] object.property)
min( [ distinct | all ] object.property)
Here is the java code for counting the records from insurance table:
|log4j:WARN No appenders
could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Hibernate: select count(*) as col_0_0_ from insurance insurance0_ group by insurance0_.ID
Total rows: 6
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.