How can i access the elements from the list created as below? I tried creating a class containing a String and an int and cast to it but it doesn't work.
List SOList = iadao.getSession().createQuery("select a.sistemOperare, count(a.sistemOperare) from User a, IstoricAfisari b, Banner c, Advertiser d where b.bannerId = c.id and c.advertiserId 开发者_StackOverflow社区= d.id and b.userId = a.id group by a.sistemOperare").list();
Thank you
This produces a List of Object arrays -> List<Object[]>
Since the createQuery(HQL).list() returns a List matching the indexes of the selected fields:
List SOList = ...
for (Object obj : SOList) {
Object[] fields = (Object[]) obj;
System.out.println("sistemOperare = " + fields[0] + " (count = " + fields[1] + ")");
}
Would print the results from the query, if any. According to hibernate documentation I could find (Since I'm more used to creating criteria for objects I want and then use Java for the rest).
精彩评论