读书人

查询回到int类型 类型转换

发布时间: 2012-09-06 10:37:01 作者: rapoo

查询返回int类型 类型转换

public Integer getCount() {   List a = null;   try {    String hql = "select count(*) from EcsPhoto";    a = super.getSession().createQuery(hql).list();    Object oc = a.get(0);    if (oc instanceof Integer) {     Integer count = (Integer) a.get(0);     return count.intValue();    } else {     Long log = (Long) a.get(0);     return log.intValue();    }   } catch (Exception e) {    e.printStackTrace();    return 0;   }}

读书人网 >软件架构设计

热点推荐