如何遍历一个List呢?
使用Hibernate
Query query = session.createQuery("select mtype,play_page from play_page");
List<String> list = query.list();
然后如何使用for循环来得到每个的mtype,play_page呢?
------解决方案--------------------
比如说:从以下两张表取数据
T_User
userId varchar(10) not null primary key,
username varchar(20)
T_Userfriend
userId varchar(10) not null,
friendId varchar(10) not null,
id int(10) primary key auto increment
(POJO名和表名相同)
Java code
Iterator iterator=session.createQuery(SELECT T_User.userId,T_User.username,T_Userfriend.friendId FROM
WHERE T_User.userId=T_Userfriend.userId).iterator();
while(iterator.hasNext()){
Object []results=(Object [])iterator.next();
String userId=String.valueOf(result[0]);
String username=String.valueOf(result[1]);
String friendId=String.valueOf(result[2]);
}