67,512
社区成员
发帖
与我相关
我的任务
分享
public Collection<Item> getItems(String userName){
Collection<Item> list = null;
Collection<Item> rtnList = null;
try{
Session session = DataBase.getSession();
Query query = session.createQuery("select b.isbn, b.name,b.picture, b.price, s.count from Books b,ShopCar s where b.isbn = s.isbn and s.userName=?");
query.setString(0, userName);
list = query.list();
for(Object obj:list){
rtnList.add((Item)obj)
}
}finally{
DataBase.closeSession();
}
return rtnList;
}
public Collection<Item> getItems(String userName){
Collection<Item> list = null;
try{
Session session = DataBase.getSession();
Query query = session.createQuery("select b.isbn, b.name,b.picture, b.price, s.count from Books b,ShopCar s where b.isbn = s.isbn and s.userName=?");
query.setString(0, userName);
list = (Collection<CarItem>)query.list();
}finally{
DataBase.closeSession();
}
return list;
}