日期:2014-05-18  浏览次数:20732 次

合并后的List如何再放入一个Map中?

List Inlst=originManage.find("select code,chdescirbe from Origin where code like '37%' and code=substr(code,1,4)||'00' order by tabIndex desc");

List Outlst=originManage.find("select code,chdescirbe from Origin where code not like '37%' and code=substr(code,1,2)||'0000' order by tabIndex desc");

并入一个List中
List Originlst=new ArrayList(); 
Originlst.add(Inlst);
Originlst.add(Outlst);

希望把合并后的List再放入一个Map,然后页面中遍历用。


------解决方案--------------------
直接用list遍历就可以了啊~
------解决方案--------------------
探讨
直接用list遍历就可以了啊~

------解决方案--------------------
抛出异常: 
java.lang.ClassCastException: java.util.ArrayList incompatible with com.sdbys.service.dict.origin.DictOrigin


类型转换异常,看看DictOrigin这个对象跟你的sql取出来的是否一致,也只有那2个元素。
------解决方案--------------------
List Inlst=originManage.find("select code,chdescirbe from Origin where code like '37%' and code=substr(code,1,4)||'00' order by tabIndex desc"); 

List Outlst=originManage.find("select code,chdescirbe from Origin where code not like '37%' and code=substr(code,1,2)||'0000' order by tabIndex desc"); 

每个list里面存放其实不是Origin实体,而是Obejct[],你只有将Object[]转换为实体才行,如hql语句
 select new Origin(o.code,o.chdescirbe from Origin as o where code like '37%' and code=substr(code,1,4)||'00' order by tabIndex desc)
并且在实体类中存在Origin(code,chdescirbe)的构造函数,才能转换为相应的实体。
------解决方案--------------------
等待...