hibernate问题

07-05-18 ouguanghong
public List getBbsReply(int tid) throws Exception {
System.out.print("进入getBbsReply");
Transaction tx=null;
List list=null;
try{
Query query=(Query)session.createQuery("from BbsReply as bbsReply where bbsReply.bbsTopic.tid=:tid");
query.setInteger("tid",tid);
list=query.list();
//System.out.print("list大小"+list.size());
for(Iterator it=list.iterator();it.hasNext();){
BbsReply bbsReply=(BbsReply)it.next();
BbsUser bbsUser=bbsReply.getBbsUser();
System.out.print(bbsUser.getUname());//该行起导航作用不能注释掉
}
return list;
}catch(Exception e){
if(tx!=null){
tx.rollback();
}
throw e;
}
finally{
session.close();
}