1. 程式人生 > >query.setFirstResult(0),query.setMaxResults(4)

query.setFirstResult(0),query.setMaxResults(4)

forum ets order by SQ sql rom session ring ESS

query.setFirstResult(0),query.setMaxResults(1);相當於MySQL中的limit 0, 1;

String hql = "FROM Forum f WHERE f.position < ? ORDER BY f.position DESC";
Query query = this.getSession().createQuery(hql);
query.setParameter(0, p1);
query.setFirstResult(0);
query.setMaxResults(1);
Forum forum2 = (Forum) query.uniqueResult();

query.setFirstResult(0),query.setMaxResults(4)