user3854150
user3854150

Reputation: 19

How can I get multiple entities values from a table in Hibernate?

String strhql="select max(e.salary),min(e.salary),avg(e.salary) from Employee e";
Query q=s.createQuery(strhql);
List l=q.list();

Upvotes: 0

Views: 35

Answers (1)

RNJ
RNJ

Reputation: 15552

This is returning a list of objects

Effectively

List l = q.list()

could be 'typed' to

List<Object[]> l = (List<Object[]>) q.list();

then you can do

 maxSal = (Integer)l.get(0)[0]

etc etc

Your question could be clearer but I think this is the answer to what you are asking. If not then please add more details to the question

Upvotes: 1

Related Questions