protected Criteria setPageParameter(final Criteria c, final Page<T> page) {
    c.setFirstResult(page.getFirst() - 1);
    c.setMaxResults(page.getPageSize());

    if (page.isOrderBySetted()) {
      String[] orderByArray = StringUtils.split(page.getOrderBy(), ',');
      String[] orderArray = StringUtils.split(page.getOrder(), ',');

      for (int i = 0; i < orderByArray.length; i++) {
        if (Page.ASC.equals(orderArray[i])) {
          c.addOrder(Order.asc(orderByArray[i]));
        } else {
          c.addOrder(Order.desc(orderByArray[i]));
        }
      }
    }
    return c;
  }
 protected Query setPageParameter(final Query q, final Page<T> page) {
   q.setFirstResult(page.getFirst() - 1);
   q.setMaxResults(page.getPageSize());
   return q;
 }