hashmap与iterator的转换问题
@Transactional(readOnly=true)publicList<Stu>getDataByDno(Studc,PageHelperpage,Pserchc...
@Transactional(readOnly = true)
public List<Stu> getDataByDno(Stu dc, PageHelper page,Pserchcon con) {
Map<String, Object> params = new HashMap<String, Object>();
String hql="select g.id as id from Stu g";
List <Stui>lst = dao.find(hql +whereHql(dc, params,con) + orderHql(page), params, page.getPage(),page.getRows());
return lst; }
Integer in = testserv.save(goods);
Test fhd = Testserv.getById(in);
List<Stu> l = new ArrayList<Stu>();
l= stusserv.getDataByDno(real, ph,con);
Iterator<Stu> iter;
iter=l.iterator();
while(iter.hasNext()){
Stu str =(Stu) iter.next(); //这句转化不成功,报错
System.out.println("222");}
代码如上,运行的时候Stu str=(Stu) iter.next();这句运行不成功 系统报错为java.util.HashMap cannot be cast to model.Stu
求解该怎么改! 感谢! 展开
public List<Stu> getDataByDno(Stu dc, PageHelper page,Pserchcon con) {
Map<String, Object> params = new HashMap<String, Object>();
String hql="select g.id as id from Stu g";
List <Stui>lst = dao.find(hql +whereHql(dc, params,con) + orderHql(page), params, page.getPage(),page.getRows());
return lst; }
Integer in = testserv.save(goods);
Test fhd = Testserv.getById(in);
List<Stu> l = new ArrayList<Stu>();
l= stusserv.getDataByDno(real, ph,con);
Iterator<Stu> iter;
iter=l.iterator();
while(iter.hasNext()){
Stu str =(Stu) iter.next(); //这句转化不成功,报错
System.out.println("222");}
代码如上,运行的时候Stu str=(Stu) iter.next();这句运行不成功 系统报错为java.util.HashMap cannot be cast to model.Stu
求解该怎么改! 感谢! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询