Пример #1
0
 @Override
 public <T> List<T> find(
     Class<T> clazz,
     Query query,
     int firstResult,
     int maxResults,
     HibernateParameter... parameters) {
   Query q = HibernateTool.setParameters(query, parameters);
   return (List<T>) HibernateTool.setPaging(q, firstResult, maxResults).list();
 }
Пример #2
0
 @Override
 public <T> List<T> findAll(Class<T> clazz, int firstResult, int maxResults, Order... orders) {
   Criteria criteria = getSession().createCriteria(clazz);
   if (orders == null || orders.length == 0) {
     return (List<T>) HibernateTool.setPaging(criteria, firstResult, maxResults).list();
   } else {
     criteria = HibernateTool.addOrders(criteria, orders);
     criteria = HibernateTool.setPaging(criteria, firstResult, maxResults);
     return (List<T>) criteria.list();
   }
 }
Пример #3
0
 @Override
 public <P> Page<P> reportPage(
     Class<P> projectClass, ProjectionList projectionList, Criteria criteria, Pageable pageable) {
   Criteria report = buildProjectionCriteria(projectClass, criteria, projectionList, false);
   long totalCount = count(report);
   List<P> items = HibernateTool.setPaging(report, pageable).list();
   return new PageImpl<P>(items, pageable, totalCount);
 }
Пример #4
0
 @Override
 public long count(Query query, HibernateParameter... parameters) {
   return (Long)
       HibernateTool.setParameters(query, parameters)
           .setResultTransformer(CriteriaSpecification.PROJECTION)
           .setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY)
           .uniqueResult();
 }
Пример #5
0
 @Override
 public <T> List<T> findAll(Class<T> clazz, Order... orders) {
   if (orders == null || orders.length == 0) {
     return (List<T>) getSession().createCriteria(clazz).list();
   } else {
     Criteria criteria = getSession().createCriteria(clazz);
     return (List<T>) HibernateTool.addOrders(criteria, orders).list();
   }
 }
Пример #6
0
 @Override
 public <P> List<P> reportList(
     Class<P> projectClass,
     ProjectionList projectionList,
     Criteria criteria,
     int firstResult,
     int maxResults) {
   Criteria report = buildProjectionCriteria(projectClass, criteria, projectionList, false);
   return (List<P>) HibernateTool.setPaging(report, firstResult, maxResults).list();
 }
Пример #7
0
  @Override
  public <T> Page<T> getPage(Class<T> clazz, Criteria criteria, Pageable pageable) {
    Criteria countCriteria = HibernateTool.copyCriteria(criteria);
    long totalItemCount = count(countCriteria);

    List<T> items =
        find(
            clazz,
            criteria,
            pageable.getPageNumber() * pageable.getPageSize(),
            pageable.getPageSize(),
            CriteriaTool.toOrders(pageable.getSort()).toArray(new Order[0]));
    return new PageImpl<T>(items, pageable, totalItemCount);
  }
Пример #8
0
 @Override
 public int executeUpdate(Query query, HibernateParameter... parameters) {
   return HibernateTool.setParameters(query, parameters).executeUpdate();
 }
Пример #9
0
 @Override
 public <T> T findUnique(Class<T> clazz, Query query, HibernateParameter... parameters) {
   return (T) HibernateTool.setParameters(query, parameters).uniqueResult();
 }
Пример #10
0
 @Override
 public <T> List<T> find(Class<T> clazz, Query query, HibernateParameter... parameters) {
   return (List<T>) HibernateTool.setParameters(query, parameters).list();
 }
Пример #11
0
 @Override
 public <T> List<T> find(
     Class<T> clazz, Criteria criteria, int firstResult, int maxResults, Order... orders) {
   Criteria cri = HibernateTool.addOrders(criteria, orders);
   return (List<T>) HibernateTool.setPaging(cri, firstResult, maxResults).list();
 }
Пример #12
0
 @Override
 public <T> List<T> find(Class<T> clazz, Criteria criteria, Order... orders) {
   return (List<T>) HibernateTool.addOrders(criteria, orders).list();
 }
Пример #13
0
 @Override
 public ScrollableResults scroll(
     Query query, ScrollMode scrollMode, HibernateParameter... parameters) {
   return HibernateTool.setParameters(query, parameters).scroll(scrollMode);
 }