Comment

Thanu
Best way,
March 27, 2009 at 6:57 AM

you can modify the code like this

package roseindia.tutorial.hibernate;

import java.util.Iterator;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateHQLAvgFunction {

/**
* @Thanu
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

Session sess = null;
try {
SessionFactory fact = new Configuration().configure().buildSessionFactory();
sess = fact.openSession();

String SQL_QUERY = "select avg(insurance.investementAmount) from Insurance insurance";
Query query = sess.createQuery(SQL_QUERY);
System.out.println("Average of Invested Amount: " + query.uniqueResult());

}
catch(Exception e){
e.printStackTrace();
}
}

}

View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
Hibernate-Tutorials

Hibernate criteria avg.
Hibernate criteria avg. In this example, you will see the use of avg() method... this application it will display message as shown below: Hibernate: select avg(this_.fee) as y0_ from studentinfo this_ Average value of fee 

Hibernate Questions

Hibernate criteria query using avg()
Hibernate criteria query using avg()  How to calculate average in Hibernate criteria query using Projection?   You can calculate average...(employee); } } } Output- Hibernate: select avg 

Hibernate Questions

hibernate best practices - Hibernate
hibernate best practices   Hi all, I am working on hibernate. can any one please send me the best practices in hibernate. And please send... for more information. http://www.roseindia.net/hibernate 

Hibernate-Tutorials

Hibernate avg() Function
Hibernate avg() Function In this tutorial you will learn about the HQL aggregate avg() function in hibernate. An avg() function in HQL performs... avg(numeric_Property_Name) from ClassName Hibernate allows the different 

Hibernate Tutorial Example

Hibernate Avg() Function (Aggregate Functions)
Hibernate Avg() Function (Aggregate Functions)  ... to use the avg() function. Hibernate supports multiple aggregate functions. When they are used in HQL queries, they return an aggregate value ( such as avg 

Hibernate Questions

Best Practice in Criteria handling? - Hibernate
Best Practice in Criteria handling?  Please explain best Practices in Hibernate Criteria handling?  Hi friend, i am sending hibernate... information, http://www.roseindia.net/hibernate Thanks (Roseindia 

Hibernate Questions

hibernate
hibernate  Is there any other way to call procedure in hibernate other than named query????? if we are using session object to get the connection then why hibernate we can directly call by using a simple java class??????? please 

Hibernate Questions

sum and avg function using HQL.
of all salary : 275000 Hibernate: select avg(employee0_.salary) as col_0_0_ from...sum and avg function using HQL.  How to use sum and avg function in HQL?   HQL supports many aggregate functions. Sum and avg are some 

Hibernate Interview Questions

Hibernate - Hibernate Interview Questions
hibernate interview questions and answers  Hi, Can anyone give me the best reference of hibernate interview questions and answers?Thanks in advance 

Java Technology Tutorials

JPA Avg Function
JPA Avg Function       In this section, you will learn the avg of aggregate function. This method calculate an average of  given data. JPA Avg() function 

Hibernate Interview Questions

Hibernate:What is hibernate?
| Hibernate | Database Server Hibernate provide a way of mapping... | Database Server Hibernate provide a way of mapping of applications class...Hibernate:What is hibernate?  What is hibernate?    

Hibernate Questions

Hibernate Annotattions - Hibernate
. The Hibernate Annotations is the powerful way to provide the metadata for the Object...Hibernate Annotattions  Can anybody tell me here how we can use hibernate annotations which is a new facility in hibernate 3.2 any tutorial and what 

Hibernate Questions

struts - hibernate doubt
struts - hibernate doubt  Hello. I'm developing a web application using Struts 1.0 and Hibernate (I'm a beginner). I've been reading your web and I've seen that in the Struts Action methods you use an Hibernate Plugin 

Hibernate Questions

HIbernate call for sequence - Hibernate
HIbernate call for sequence  I have created a sequence in oracle table. Now how to access this in java class through hibernate from dual table i am..._S is this the right way to retrive the next value from 

Hibernate Interview Questions

HIBERNATE
HIBERNATE   What is difference between Jdbc and Hibernate 

Hibernate Interview Questions

hibernate
hibernate  what is hibernate flow 

Hibernate Questions

hibernate
hibernate  what is hibernate listeners 

Hibernate Questions

hibernate
hibernate  what is hibernate why we use 

Hibernate Questions

Hibernate
Hibernate  hibernate delete query execution 

Java Beginners

hibernate
hibernate  how to uses optional column in hibernate 

Hibernate Questions

Hibernate
Hibernate  how to use pagination concept in Hibernate 

Hibernate Questions

hibernate
hibernate  please give me the link where i can freely download hibernate software(with dependencies)   Learn hibernate, if you want to learn hibernate, please visit the following link: Hibernate Tutorials 

Hibernate Questions

hibernate
hibernate   I want to learn how to use hibernate framework in web application . for storing database in our application 

Hibernate Questions

hibernate
hibernate   I want to learn how to use hibernate framework in web application . for storing database in our application 

Hibernate Questions

What is hibernate ?
Hibernate provide a way of mapping of applications class to the database table...What is hibernate ?   What is hibernate ? explain with simple example.   Hibernate is an Open Source persistence technology. It provides 

Java Beginners

Best way to reading file in java
Best way to reading file in java  Hi, As a beginner I want to learn about Java programming and make a program for reading a text file in java. What is the best way for reading file in Java? Thanks 

Hibernate Questions

hibernate
why hibernate?  why hibernate?   Hibernate: -Hibernate... library. It solves object-relational impedance mismatch problems. Hibernate makes the application development process easy Hibernate saves the development 

Hibernate Questions

Hibernate
Hibernate  Please tell me the difference between hibernate and jdbc 

Hibernate Questions

hibernate
hibernate  why we should use hibernate projection 

Java Beginners

hibernate
hibernate  pls give one simple example program for hibernate 

Hibernate Questions

hibernate
hibernate  how to execute a sequence(in database) from Hibernate program or java program   Please visit the following link: Hibernate Tutorials 

Hibernate Questions

hibernate
hibernate  can any one one explain what is hibernate ?   Please visit the following link: Hibernate Tutorials 

Hibernate Questions

Hibernate
Hibernate  hello, how to run hibernate program in netbeans?please send me step by step instructions to run hibernate in netbeans 

Hibernate Interview Questions

Hibernate
Hibernate  How do you handle parent - child tables relationships in hibernate? How do you handle Detach state in hibernate 

Hibernate Questions

Hibernate proxy
Hibernate proxy  What is Hibernate proxy?   An object proxy is just a way to avoid retrieving an object until you need it. Hibernate 2 does... proxies is preferred, so this is the default in Hibernate 3. Object proxies can 

Hibernate Questions

Hibernate criteria average Example
the tutorial Hibernate criteria avg.. Check the Latest tutorials, articles...Hibernate criteria average Example   How to find the average in Hibernate? Thanks   Example of finding average on a filed in Hibernate 

Hibernate Questions

Hibernate - Hibernate
Hibernate Features  Hibernate features in eclipse 

Hibernate Questions

Hibernate
Hibernate  hi sir i need hibernate complete tutorial for download   Hi Friend, Please visit the following link: Hibernate Tutorials Thanks 

Hibernate Questions

hibernate
hibernate  how to impot mysql database client jar file into eclipse for hibernate configuration   Hi Friend, Please visit the following link: http://www.roseindia.net/hibernate/runninge-xample.shtml Thanks 

Hibernate Interview Questions

HIBERNATE
HIBERNATE  How u connects database using hibernate 3.0? Where you have written the database configuration details 

Hibernate Questions

hibernate
hibernate  hi what are the necessary jar files that we need to set in the classpath to execute a hibernate application 

Hibernate Questions

hibernate
hibernate  How to know how many columns changed in a table when we are using hibernate 

Hibernate Questions

hibernate
hibernate   i am using hibernate3.2.5 and oracle9i. First i set classpath to ojdbc14.jar and all the hibernate jar files to path env variable.After that when i try to execute the program i got an error "unknown oracle major 

Hibernate Questions

hibernate
hibernate  when we using schemaExport in hibernate every time it drops the existing table and create new table ,if table contain dependent table then is it drop 

Hibernate Questions

Hibernate
of Hibernate. I followed all th steps as given in the tutorial, but a build error... hibernate library files are not included in the project build path. Please download the example from Hibernate Getting Started Tutorial. Please follow the steps 

Struts Questions

Hibernate Integration
Hibernate Integration  I am doing project using Struts 2,Eclipse Galileo IDE, MySQL Server and Hibernate. I can't able to do the insert,update,delete operation in any way. I have done much things but still now I found difficulty 

Hibernate Questions

Hibernate
Hibernate  Can we write more than one hibernate.cfg.xml file... ? if so how can we call and use it.? can we connect to more than one DataBase from a single Hibernate program 

Hibernate Questions

Hibernate
Hibernate  Hi i have 2 doubbts regarding Hibernate ,.. 1)Can we rename hibernate.cfg.xml? 2? can we use multiple mapping resource in hibernate.cf.xml file ? pls let me know soon 

Hibernate Questions

Hibernate - Hibernate
Hibernate sessionfactory configuration  What is the process of hibernate sessionfactory configuration 

Hibernate Questions

hibernate - Hibernate
hibernate program shareware  hibernate program shareware example 

Hibernate Tutorial Example

What is Hibernate in Java?
for the information about the Hibernate ORM? Then this is the best place to learn about... is a way to provide the mapping metadata to the Hibernate runtime.  ...What is Hibernate in Java? - Hibernate is ORM tool in Java. Are you beginner 

Hibernate Questions

hibernate
;Hi Friend, Please visit the following link: http://www.roseindia.net/hibernate 

Hibernate-Tutorials

Hibernate Criteria Query
Hibernate Criteria Query In this tutorial you will learn about the Hibernate Criteria Query. Hibernate provides an API for writing the dynamic query in an elegant way to execute . Except the use of HQL in Hibernate, Criteria query 

Hibernate Tutorial Example

Complete Hibernate 3.0 and Hibernate 4 Tutorial
; Hibernate Avg() Function (Aggregate Functions) In this section, we will show you, how to use the avg() function. Hibernate supports multiple...; Hibernate Books List of many best hibernate books 

Hibernate Questions

How to calculate the average in Hibernate?
") Check the tutorial for complete code example at Hibernate criteria avg. Thanks...How to calculate the average in Hibernate?  Hi, I have to calculate the average in Hibernate. How to calculate the average in Hibernate? Thanks 

Hibernate Questions

Detachedcriteria in hibernate
in hibernate for given Query?   Detached Criteria query is a facility provide by Hibernate to write criteria queries in ?detached mode?, where hibernate... to import org.hibernate.criterion.DetachedCriteria; Here is a way to write 

Hibernate-Tutorials

Hibernate Video Tutorial
Roseindia.net provides you the best Hibernate video tutorials embedded... the basics of hibernate as well as advance hibernate. Hibernate, which... knowledge of hibernate becomes quite essential for the Java programmers. Our video 

Hibernate Tutorial Example

Hibernate Criteria Aggregate Functions
Hibernate Criteria Aggregate Functions The Hibernate Criteria Aggregate Function Supports the following function min(), max(), sum(), avg(), count(). These functions are of Projections class. Following are the way to use 

Travel

Which is the best way to travel around Delhi
Which is the best way to travel around Delhi  Please suggest us the best way to travel in and around Delhi. Thanks 

Hibernate Questions

Hibernate - Hibernate
Hibernate application development help  Hi, Can anyone help me in developing my first Java and Hibernate application 

Hibernate Questions

hibernate...............
hibernate...............  goodevining. I am using hibernate on eclipse, while connection to database Orcale10g geting error .........driver ARNING: SQL Error: 0, SQLState: null 31 May, 2012 8:18:01 PM 

Hibernate Questions

Hibernate - Hibernate
prog using hibernate query   Hibernate update query http://www.roseindia.net/hibernate/hibernate-update.shtml This will show you how to update records in hibernate! regards Meeya 

Hibernate Questions

hibernate - Hibernate
hibernate  is there any tutorial using hibernate and netbeans to do a web application add,update,delete,select   Hi friend, For hibernate tutorial visit to : http://www.roseindia.net/hibernate/index.shtml 

Hibernate Questions

Simple Example of Hibernate 4
Simple Example of Hibernate 4  Hi, As a new comer in the Hibernate programming, I want simple program of Hibernate to learn the basic concepts. Share me the best example. Thanks   Hi, Check tutorial: Hibernate

Hibernate Questions

hibernate - Hibernate
hibernate  pl send me hibernate interview questions 

Hibernate Questions

What do you understand by Hibernate in Java?
What do you understand by Hibernate in Java?  Hey, do you know about Hibernate in Java? I have to learn it for my next project. What is the best and probably most easiest way to learn this Hibernate stuff? How it is beneficial 

Hibernate Questions

hibernate - Hibernate
hibernate    what is the lazy Loading in hibernate? can you give the example table ?  Lazy Loading in Hibernate In Hibernate, Lazy... in the program's operation. The syntax of lazy loading in Hibernate... public Entity 

Hibernate Questions

Hibernate @ManyToOne persisting problem - Hibernate
Hibernate @ManyToOne persisting problem  hello, In my apllication, there are students and classes. a student can take many classes. So there is OneToMany <--> ManyToOne relationship. Im my case, the best implementation 

Hibernate Questions

hibernate - Hibernate
: http://www.roseindia.net/hibernate/hibernate-aggregate-functions.shtml http://www.roseindia.net/hibernate/associations-and-joins.shtml Thanks 

Hibernate Interview Questions

Hibernate sample code - Hibernate Interview Questions
reduces the development time. Hibernate is not the best solutions for data centric...Hibernate sample code  Hi Can any body tell me how to persist inner class,abstract class,final class,and interface in hibernate. From 

Hibernate Questions

Hibernate - Hibernate
Hibernate  how to call the stored procedure in mysql database server using hibernate..??  Hi Friend, Please visit the following link: http://www.roseindia.net/hibernate Thanks 

Hibernate Interview Questions

HIBERNATE
 

Hibernate Questions

hibernate
 

Hibernate Questions

Hibernate
 

Hibernate Questions

hibernate
 

Hibernate Questions

Hibernate
 

Hibernate Questions

Hibernate
 

Hibernate Interview Questions

Hibernate
 

Hibernate Interview Questions

hibernate
 

Hibernate Questions

hibernate
 

Hibernate Questions

Hibernate
 

Hibernate Questions

Hibernate Detached Criteria Example
then the tutorial link given below is the best place to start with the Hibernate...Hibernate Detached Criteria Example  can anyone share me the source code of using detached Criteria in Hibernate? Thanks   Hi, If you 

Hibernate Questions

Hibernate - Hibernate
Hibernate  What is a lazy loading in hibernate?i want one example of source code?plz reply 

Hibernate Questions

hibernate - Hibernate
hibernate  wts the use of inverse in hibernate? can any one explain the association mapping(1-1,1-many,many-1,many-many 

Hibernate Questions

hibernate - Hibernate
hibernate  hi friends i had one doubt how to do struts with hibernate in myeclipse ide its urgent 

Hibernate Questions

Hibernate - Hibernate
Hibernate  Give me a brief description about Hibernate?How we will use it in programming?give me one example 

JDBC Questions

the best way to generate a universally unique object ID.
the best way to generate a universally unique object ID.  What is the best way to generate a universally unique object ID? Do I need to use an external resource like a file or database, or can I do it all in memory 

Hibernate Questions

hibernate - Hibernate
hibernate  what is hibernate and how to make a pc hibernating?  Hi friend, Hibernate is based on object oriented concept like java... .properties file and in hibernate we use .xml file ,which is a better approach. We 

Hibernate Questions

hibernate - Hibernate
hibernate   hi,can any one tell me how to get SQL query in hibernate, when hql fire it will create sql in console when hibernate.cfg.xml property will true, but i want SQL query in one variable how to get it... Thanks satish 

Hibernate Questions

Hibernate - Hibernate
one example   Hi mamatha, Hibernate 3.0, the latest Open Source... not understandable for anybody learning Hibernate. Hibernate provides a solution to map.../hibernate/ Thanks. Amardeep 

Hibernate Questions

Hibernate Query - Hibernate
Hibernate Query  Hibernate Query 

Hibernate Questions

server problem - Hibernate
server problem  dear sir please give me best soloution how run hibernate and spring application on jboss and weblogic10.1.0 sever and compile thanks 

Hibernate Questions

Hibernate programming tutorial for beginner
;Hi, I think the best place to start reading the basics of Hibernate. Check...Hibernate programming tutorial for beginner  Hi, I am beginner in Hibernate and I wish to learn it quickly. I am hoping to learn the latest ORM 

Hibernate Questions

Hibernate - Hibernate
Hibernate  Hai,This is jagadhish.Iam learning Hibernate.I have a doubt in that area plz help me.That is In Hibernate mapping file I used tag...://www.roseindia.net/hibernate/ Thanks 

Java Beginners

What is the best way to write to file in Java?
What is the best way to write to file in Java?  I am creating a program in Java which writes into a text file. What can be the be best method to write to a text file in Java? Since my program will continuously write the data 

Hibernate Questions

Hibernate 4 annotations tutorial
Hibernate 4 annotations tutorial  Hi, I am trying to find the best Hibernate 4 annotations tutorial. I think there is good tutorial on your site. Please tell me the url of Hibernate 4 annotations tutorial. Thanks   hi 

Hibernate Questions

Hibernate - Hibernate
Hibernate SessionFactory  Can anyone please give me an example of Hibernate SessionFactory?  Hi friend,package roseindia;import...;1.0"?><!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate 

Hibernate Questions

Hibernate - Hibernate
Hibernate   Dear sir Thanks for your previous answers its really... ,hibernate, jboss, oracle) one is 1) Express and 2) MDM(All master data... 192.168.1.2 using hibernate(Schema name Express) In MDM i am connecting 

Hibernate Questions

Hibernate - Hibernate
. http://www.roseindia.net/hibernate/ Thanks 

Hibernate Questions

Hibernate - Hibernate
Hibernate  Hello Deepak as you answer posted this is solution of if any file not found but my question is .. Error is ::: Error in reading contact.hbm.xml contact.hbm.xml is my hibernate mapping file. So please read 

Advertisements Advertisements
 

 

 

DMCA.com