现在的位置: 首页 > 综合 > 正文

hql语句中如果没有用Map,List分组的

2014年02月03日 ⁄ 综合 ⁄ 共 789字 ⁄ 字号 评论关闭

可以用如下的代码把其中的字段取出来:      

            StringBuffer sbDeviceId = new StringBuffer();

            sbDeviceId.append("select deviceId as deviceId ,city as city, deviceType as  deviceType from  UniqueDevice  where  firstActiveTime >='" + dayBefore
                    + " 00:00:00'" + " and firstActiveTime <='" + dayBefore + " 23:59:59' and firstEffectTime is not null and firstEffectTime!='"+"'");
            sbDeviceId.append(" and city = '" + city + "'");
            sbDeviceId.append(" and deviceType = '" + deviceType + "'");

            List listDeviceId = getHibernateTemplate().find(sbDeviceId.toString());

           for (int i=0; i<listDeviceId.size(); i++) {
                Object[] object = (Object[]) listDeviceId.get(i);
                String deviceId = (String)object[0];
                String city = (String) object[1];
                String deviceType = (String) object[2];                
            }

抱歉!评论已关闭.