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();
alt + shift +a