模拟试题

3773考试网计算机等级考试模拟试题正文

2011计算机二级JAVA编程:用Hibernate实现分页

来源:fjzsksw.com 2010-11-4 14:10:10

 

 

 用Hibernate实现分页

  public List queryByStatus(int status, int currentPage, int lineSize)

  throws Exception {

  List all = null;

  String hql = "FROM Question AS q WHERE q.status=? ORDER BY q.questiontime desc";

  Query q = super.getSession().createQuery(hql);

  q.setInteger(0, status);

  q.setFirstResult((currentPage - 1) * lineSize);

  q.setMaxResults(lineSize);

  all = q.list();

  return all;

  }

 

 

触屏版 电脑版
3773考试网 琼ICP备12003406号-1