Originally posted by Syed Saifuddin:
hi Mark Spritzler
sir but in case of aggregate function like count(field) how to get this function value.
Again it is an Object[][] that is being returned, the value of the count will be one of the indexes in the object array. Objects don't have names.
So in your query, the count is the second item, so when you get a row from the Object[][] it will be the second item it the array.
so for each Object[x][y], the y will equal "1"
Now you can do another trick where you create a new object of your special type
[CODE]
public class MyObject
{
private
String student;
private int count;
public MyObject(String student, int count) {
this.student = student;
this.count = count;
}
//Getters and Setters here
}
[\CODE]
then your JPA QL could be
"select new MyObject(c.nameenglish, count(m.contact))
from Message m , Contact c where m.contact=c.id " group by m.contact";
So now you will get a Collection of MyObject, and now to get the values you would be able to call myObjectVar.getCount();
Then sort it later too.
Mark