07-08
25
根据分类查商品,一对多关系
作者:Java伴侣 日期:2007-08-25
方法如下:
复制内容到剪贴板 程序代码
public List getPtsByCateID(CategoryVO cate)
{
Transaction tx = null;
List list =null;
Session session = HibernateUtil.getSession();
try {
tx = session.beginTransaction();
list =session.find("from ProductVO as p where p.cate="+cate.getId()+"");
tx.commit();
} catch (HibernateException ex) {
ex.printStackTrace();
}
finally{
if(tx !=null)
try {
tx.rollback();
} catch (HibernateException ex1) {
}
if(session !=null)
try {
session.close();
} catch (HibernateException ex2) {
}
}
return list;
}
{
Transaction tx = null;
List list =null;
Session session = HibernateUtil.getSession();
try {
tx = session.beginTransaction();
list =session.find("from ProductVO as p where p.cate="+cate.getId()+"");
tx.commit();
} catch (HibernateException ex) {
ex.printStackTrace();
}
finally{
if(tx !=null)
try {
tx.rollback();
} catch (HibernateException ex1) {
}
if(session !=null)
try {
session.close();
} catch (HibernateException ex2) {
}
}
return list;
}
评论: 0 | 引用: 0 | 查看次数: 760
发表评论