Criteria c = getSession().createCriteria(Phone.class); if (groupId != null) { c.createCriteria("groups", "g"); c.add(Restrictions.eq("g.id", groupId)); } c.setFirstResult(firstRow); c.setMaxResults(pageSize); Order order = orderAscending ? Order.asc(orderBy) : Order.desc(orderBy); c.addOrder(order); List phones = c.list(); return phones;
return loadBeansByPage(Phone.class, groupId, firstRow, pageSize, orderBy, orderAscending);
    public List loadPhonesByPage(Integer groupId, int firstRow, int pageSize, String orderBy,            boolean orderAscending) {        Criteria c = getSession().createCriteria(Phone.class);        if (groupId != null) {            c.createCriteria("groups", "g");            c.add(Restrictions.eq("g.id", groupId));        }        c.setFirstResult(firstRow);        c.setMaxResults(pageSize);        Order order = orderAscending ? Order.asc(orderBy) : Order.desc(orderBy);        c.addOrder(order);        List phones = c.list();        return phones;    }