How to calculate the average in Hibernate?

Hi,

I have to calculate the average in Hibernate. How to calculate the average in Hibernate?

Thanks

View Answers

January 22, 2014 at 12:34 PM

Hi,

You can use the project in Hibernate. Here is the example code of calculating the average on the fee field in database:

Projections.avg("fee")

Check the tutorial for complete code example at Hibernate criteria avg.

Thanks


January 23, 2014 at 6:27 PM

In HQL query you can use the database avg() function to calculate average

select avg(pojo property name) from <Pojo class name >









Related Tutorials/Questions & Answers:
Advertisements