List mmtReplies = (List)CacheUtils.getValueFromCache("CommonData", mmtArticle.getId() + "_" + page1 + "_MMTMmtReplies");
  if (mmtReplies == null) {
  mmtReplies = this.jpaTemplate.executeFind(new JpaCallback(mmtArticle, page1) {
  public List<MMT_Reply> doInJpa(EntityManager em) throws PersistenceException {
  return em.createQuery("SELECT i FROM MMT_Reply i WHERE i.mmtArticle.id=? ORDER BY i.date DESC").setParameter(1, this.val$mmtArticle.getId()).setFirstResult((this.val$page1.intValue() - 1) * 10).setMaxResults(10).getResultList();
  }
  });
  CacheUtils.putValueToCache("CommonData", mmtArticle.getId() + "_" + page1 + "_MMTMmtReplies", mmtReplies);
  }
我想问setParameter(1, this.val$mmtArticle.getId()).setFirstResult((this.val$page1.intValue() - 1)中的this.val$mmtArticle 和 this.val$page1 是什么,,, 

解决方案 »

  1.   

    你分还真多。。
    这个功能是用来分页的,如果你觉得可读性差的话,可以改为Query query = em.createQuery("SELECT i FROM MMT_Reply i WHERE i.mmtArticle.id=? ORDER BY i.date DESC");
    query.setParameter(1, this.val$mmtArticle.getId())
    query.setFirstResult((this.val$page1.intValue() - 1) * 10)
    query.setMaxResults(10)
    query.getResultList();//query.setFirstResult(xx);表示从第xx条开始截取
    //query.setMaxResults(yy);表示截取yy条数据
      

  2.   


    ,,,,,,,,我能看出是做分页,关键是this.val$mmtArticl 和 this.val$page1 这两个我确实找不出是在哪里声明的