查询
VoteDAO dao=new VoteDAO();
Vote vote=new Vote();
vote=(Vote)dao.getSession().createQuery( "from Vote ").list().iterator().next();
out.println( " <tr> ");
out.println( " <td> <input type= 'radio ' name= 'rad ' value= ' "+vote.getId()+ " '> ");
out.println(vote.getItem());
out.println( " </td> ");
out.println( " </tr> ");
我想在数据库中把所有的记录都查询出来,但是现在只能输出一条记录.把全部记录输出来要怎样写啊?????
------解决方案-------------------- List vote;//类型为List
vote=(Vote)dao.getSession().createQuery( "from Vote ").list();
for (Iterator iter = vote.iterate(); iter.hasNext(); ) {
Vote vote = (Vote) iter.next();
System.out.println(第一个vote);
}