How to calculate the average in Hibernate?

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:
How to calculate the average in Hibernate?
How to calculate average of array in Java?
Advertisements
calculate average
calculate average
Calculate sum and Average in java
Calculate an average Age of my Class?
Feature of Hibernate3
How to calculate attending hours?
How to calculate days in a year
how to calculate the price on the option box
Average
how to calculate EMI of the loan
How to calculate area of rectangle
Maven dependency for org.grails.plugins - hibernate5 version 7.0.6 is released. Learn to use hibernate5 version 7.0.6 in Maven based Java projects
Maven dependency for org.grails.plugins - hibernate5 version 7.0.7 is released. Learn to use hibernate5 version 7.0.7 in Maven based Java projects
Maven dependency for org.grails.plugins - hibernate5 version 7.0.5 is released. Learn to use hibernate5 version 7.0.5 in Maven based Java projects
How to calculate Date Difference in Java?
how to calculate the employee tax - JSP-Servlet
How to calculate sum of HH:MM:SS Format?
how to calculate max and min - RUP
how to write weighted moving average code using 2d-array
What is the main feature of Hibernate3?
Maven Repository/Dependency: org.grails.plugins | hibernate5
Maven Repository/Dependency: hibernate | hibernate3
How to calculate number of weeks in a specified month
How to calculate area of triangle
MySQL Average Command
how to calculate max and min in the loop - Java Beginners
Average of Array
struts1.2,EJB3.0 and Hibernate3 integration example application - EJB
how to calculate salary of all the employees 10%extra then actual salary - SQL
Highest average score among 25 students
PHP Get Average - PHP
how can i calculate loan - Java Interview Questions
ModuleNotFoundError: No module named 'average'
how to find [count the number of integers whose value is less than the average value of the integers]
sum and average of grades
how to print the average of each column of 2d n*m array using java
how can you calculate you your age in daies??
Student average
Hibernate criteria average Example
How to calculate minimum in Hibernate using the min() Function
how to calculate addition of two distances in feets and inches using objects as functions arguments
Average Age of my Class?
calculate reward points.
Determine Average by removing Largest and Smallest Number
ModuleNotFoundError: No module named 'calculate'
Calculate Company's Sale using Java
ModuleNotFoundError: No module named 'average-pixels'
ModuleNotFoundError: No module named 'django-average'

Ads