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 EMI of the loan
how to calculate the price on the option box
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
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
How to calculate area of rectangle
How to calculate Date Difference in Java?
Average
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?
How to calculate area of triangle
How to calculate number of weeks in a specified month
how to calculate max and min in the loop - Java Beginners
MySQL Average Command
how to calculate salary of all the employees 10%extra then actual salary - SQL
Average of Array
struts1.2,EJB3.0 and Hibernate3 integration example application - EJB
how can i calculate loan - Java Interview Questions
Highest average score among 25 students
how to find [count the number of integers whose value is less than the average value of the integers]
how to print the average of each column of 2d n*m array using java
how can you calculate you your age in daies??
PHP Get Average - PHP
How to calculate minimum in Hibernate using the min() Function
ModuleNotFoundError: No module named 'average'
sum and average of grades
how to calculate addition of two distances in feets and inches using objects as functions arguments
Student average
calculate reward points.
Average Age of my Class?
Hibernate criteria average Example
Determine Average by removing Largest and Smallest Number
Calculate Company's Sale using Java
ModuleNotFoundError: No module named 'calculate'
ModuleNotFoundError: No module named 'average-pixels'
ModuleNotFoundError: No module named 'average-pixels'
ModuleNotFoundError: No module named 'Dice-Average'
ModuleNotFoundError: No module named 'django-average'
ModuleNotFoundError: No module named 'django-average'

Ads