public int getAllCount() throws Exception {
int count = 0;
String hql = "SELECT COUNT(p.id) from Person AS p";
Query q = this.getSession().createQuery(hql);
List all = q.list();
if (all.size() > 0) {
count = (Integer) all.get(0);
}
return count;
} public int getByLikeCount(String cond) throws Exception {
int count = 0;
String hql = "SELECT COUNT(p.id) from Person AS p WHERE p.uid LIKE ? OR p.name LIKE ?";
Query q = this.getSession().createQuery(hql);
q.setString(0, "%" + cond + "%");
q.setString(1, "%" + cond + "%");
List all = q.list();
if (all.size() > 0) {
count = (Integer) all.get(0);
}
return count;
} public List queryAll(int currentPage, int lineSize) throws Exception {
List<Person> all = new ArrayList<Person>();
String hql = "FROM Person AS p";
Query q = this.getSession().createQuery(hql);
q.setFirstResult((currentPage - 1) * lineSize);
q.setMaxResults(lineSize);
all = q.list();
return all;
} public List queryByLike(String cond, int currentPage, int lineSize)
throws Exception {
List<Person> all = new ArrayList<Person>();
String hql = "FROM Person AS p WHERE p.uid LIKE ? OR p.name LIKE ?";
Query q = this.getSession().createQuery(hql);
q.setString(0, "%" + cond + "%");
q.setString(1, "%" + cond + "%");
q.setFirstResult((currentPage - 1) * lineSize);
q.setMaxResults(lineSize);
all = q.list();
return all;
}把上面mysql分页的代码怎么转成orcal中的呀