public int getByItemCount(int itemid) throws Exception { int count = 0 ;
String hql = "select count(q.qid) form Question as q where q.itemid=?";
Query q = super.getSession().createQuery(hql);
q.setInteger(0, itemid);
List all = q.list();
count = (Integer)all.get(0);
return count;
}all.get(0) 在Hibernate中得到的是一个对象, (Integer)+对象 得到是不是也是一个对象呢?但这个函数返回的是int 类型的啊,,,,,,
大家给解释一下,,,,指出小弟的错误,,,,,,,
String hql = "select count(q.qid) form Question as q where q.itemid=?";
Query q = super.getSession().createQuery(hql);
q.setInteger(0, itemid);
List all = q.list();
count = (Integer)all.get(0);
return count;
}all.get(0) 在Hibernate中得到的是一个对象, (Integer)+对象 得到是不是也是一个对象呢?但这个函数返回的是int 类型的啊,,,,,,
大家给解释一下,,,,指出小弟的错误,,,,,,,
楼主【qhmao】截止到2008-07-15 16:10:20的历史汇总数据(不包括此帖):
发帖的总数量:28 发帖的总分数:112 每贴平均分数:4
回帖的总数量:27 得分贴总数量:2 回帖的得分率:7%
结贴的总数量:28 结贴的总分数:112
无满意结贴数:11 无满意结贴分:59
未结的帖子数:0 未结的总分数:0
结贴的百分比:100.00% 结分的百分比:100.00%
无满意结贴率:39.29 % 无满意结分率:52.68 %
敬礼!
Integer类型可以自动转换成int类型,编译器帮你做了这件事情。
public class Test {
public static void main(String[] args) {
Integer i=3;//从int类型自动转换到Integer类型
System.out.println(i.intValue());
int b=i;//从对象类型自动转换为int类型
System.out.println(b);
//
ArrayList list=new ArrayList<Integer>();
list.add(5);
Integer temp=(Integer)list.get(0);
System.out.println(temp);
int t=temp;
System.out.println(t);
}
}
一个简单的例子,看看就明白了。