从项目中拷的代码,仅供参考。
public Map<String, List<Map<String, String>>> getStaticinfo(String compId){
JSONObject json = new JSONObject();
String hql = "select cde.id as id, ctpe.name as name, cde.value as value,ctpge.groupname , cde.compTypeId " +
"from ComponentDatumEntity cde,ComponentTypeParamEntity ctpe ,ComponentTypeParamGroupEntity ctpge" +
"where cde.paramId = ctpe.id and ctpe.paramGroupId = ctpge.id " +
" and cde.compTypeId= '"+compId+"' ";
List<Object[]> allDatalist = dao.queryOrgByHql(hql);
Map<String, List<Map<String, String>>> groupMap = new HashMap<String, List<Map<String,String>>>();
List<Map<String, String>> list = null;
Map<String, String> p = null;
for (Object[] obj : allDatalist) {
list = groupMap.get(String.valueOf(obj[3]));
if(null == list){
list = new ArrayList<Map<String,String>>();
groupMap.put(String.valueOf(obj[3]), list);
}
p = new HashMap<String, String>();
p.put("name", String.valueOf(obj[1]));
p.put("value", String.valueOf(obj[2]));
list.add(p);
}
return groupMap;
}