jave吧 关注:851贴子:1,250
  • 0回复贴,共1

关于hibernate呵Struts

只看楼主收藏回复

这是DaoHibernate的
public List<T> findAll12(String hql,int cid, int begin, int size) throws SQLException {
List<T> list=null;
Session s=null;
try{
s=HibernateUtil.getThreadLocalSession();
Query query=s.createQuery(hql);
query.setMaxResults(size);
query.setFirstResult(begin);
list=query.list();
}finally {
HibernateUtil.closeSession();}
return list;
}
ProductDao
public class ProductDao extends DaoHibernate<Product> {
public List<Product> findByCatId(int cid, int begin, int size) throws SQLException {
String hql="select dp ,db from d_category_product as dcp,d_product as dp ( where dcp.product_id=dp.id ),d_book as db (where dp.id=db.id) where dcp.cat_id=?;" ;
List<Product> Plist=this.findAll12(hql,cid,begin,size);
// List<Product> list=new ArrayList<Product>();
// for(Product p:Plist) {
// list.add(p);
// }
return Plist;
}
有什么不对吗,求大佬指点。。。。。。。求大佬


1楼2019-01-01 20:33回复