我有一个对象:
[code="java"]class User{
private int id;
private String name;
private int age;
//setter/getter...
}[/code]
其他配置都弄好了,我写查询的测试代码如下:
[code="java"]ProjectionList projectionList=Projections.projectionList();
projectionList.add(Projections.groupProperty("age"));
projectionList.add(Projections.rowCount());
criteria.setProjection(projectionList);
List list=criteria.list();
//-----------打印结果---------------
List list=criteria.list();
Iterator it1=list.iterator();
while(it1.hasNext()){
System.out.println(it1.next());
}[/code]
结果:Hibernate: select this_.age as y0_, count(*) as y1_ from quser this_ group by this_.age
[Ljava.lang.Object;@eaf40c
[Ljava.lang.Object;@13c6641
[Ljava.lang.Object;@5d391d
从hibernate转化的sql语句可以看出,查询得到了age和人数,那我怎么取出来呢,我得到的是一个List,而List里面都是Object,怎么取?[code="java"][/code]