当前位置: 首页>>代码示例>>Java>>正文


Java Pageable.getOffset方法代码示例

本文整理汇总了Java中org.springframework.data.domain.Pageable.getOffset方法的典型用法代码示例。如果您正苦于以下问题:Java Pageable.getOffset方法的具体用法?Java Pageable.getOffset怎么用?Java Pageable.getOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.data.domain.Pageable的用法示例。


在下文中一共展示了Pageable.getOffset方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createOptions

import org.springframework.data.domain.Pageable; //导入方法依赖的package包/类
/**
 * build options map for tarantool paging request
 * @param pageable spring-data pageable (page size and offset provider)
 * @param iterator tarantool iterator
 * @return map to push into tarantool
 */
public static Map<String, Object> createOptions(Pageable pageable, Iterator iterator) {
    Map<String, Object> options = new HashMap<>();
    if (pageable.getPageSize() != Integer.MAX_VALUE) {
        options.put("limit", pageable.getPageSize());
    }
    if (pageable.getOffset() != 0) {
        options.put("offset", pageable.getOffset());
    }
    if (iterator != null) {
        options.put("iterator", iterator.getValue());
    }
    return options;
}
 
开发者ID:saladinkzn,项目名称:spring-data-tarantool,代码行数:20,代码来源:TarantoolPageUtils.java

示例2: fromPageable

import org.springframework.data.domain.Pageable; //导入方法依赖的package包/类
private <T> Stream<T> fromPageable(Page<T> result, Pageable pageable,
        Query<T, ?> query) {
    List<T> items = result.getContent();

    int firstRequested = query.getOffset();
    int nrRequested = query.getLimit();
    int firstReturned = (int) pageable.getOffset();
    int firstReal = firstRequested - firstReturned;
    int afterLastReal = firstReal + nrRequested;
    if (afterLastReal > items.size()) {
        afterLastReal = items.size();
    }
    return items.subList(firstReal, afterLastReal).stream();
}
 
开发者ID:Artur-,项目名称:spring-data-provider,代码行数:15,代码来源:PageableDataProvider.java

示例3: findAll

import org.springframework.data.domain.Pageable; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
/**
 * 分页条件查询
 * @param cq 条件
 * @param pageable 分页信息
 * @param <T> 领域类(实体类)范型
 * @return 分页结果
 */
public static <T> Page<T> findAll(CriteriaQuery<T> cq, Pageable pageable) {
	Class<T> domainClass = cq.getResultType();
	Root<T> root;
	if (CollectionUtils.isEmpty(cq.getRoots())) {
		root = cq.from(domainClass);
	} else {
		root = (Root<T>) cq.getRoots().iterator().next();
	}
	EntityManager em = getEntityManager(domainClass);
	if (pageable == null) {
		List<T> list = findAll(cq);
		return new PageImpl<T>(list);
	} else {
		Sort sort = pageable.getSort();
		cq.orderBy(QueryUtils.toOrders(sort, root, em.getCriteriaBuilder()));
		TypedQuery<T> query = em.createQuery(cq);
		
		query.setFirstResult(pageable.getOffset());
		query.setMaxResults(pageable.getPageSize());

		Long total = count(cq);
		List<T> content = total > pageable.getOffset() ? query.getResultList() : Collections.<T> emptyList();

		return new PageImpl<T>(content, pageable, total);
	}
}
 
开发者ID:muxiangqiu,项目名称:linq,代码行数:35,代码来源:JpaUtil.java

示例4: paging

import org.springframework.data.domain.Pageable; //导入方法依赖的package包/类
@Override
public <T> Page<T> paging(Pageable pageable) {
	if (parent != null) {
		applyPredicateToCriteria(sq);
		return parent.paging(pageable);
	}
	List<T> list;
	if (pageable == null) {
		list = list();
		return new PageImpl<T>(list);
	} else {
		Sort sort = pageable.getSort();
		if (sort != null) {
			orders.addAll(QueryUtils.toOrders(sort, root, cb));
		}
		applyPredicateToCriteria(criteria);
		TypedQuery<?> query = em.createQuery(criteria);
		
		query.setFirstResult(pageable.getOffset());
		query.setMaxResults(pageable.getPageSize());

		Long total = JpaUtil.count(criteria);
		List<T> content = Collections.<T> emptyList();
		if (total > pageable.getOffset()) {
			content = transform(query, false);
		}

		return new PageImpl<T>(content, pageable, total);
	}
}
 
开发者ID:muxiangqiu,项目名称:linq,代码行数:31,代码来源:LinqImpl.java

示例5: readPage

import org.springframework.data.domain.Pageable; //导入方法依赖的package包/类
@Override
protected Page<T> readPage(final TypedQuery<T> query, final Pageable pageable, final Specification<T> spec) {
    query.setFirstResult(pageable.getOffset());
    query.setMaxResults(pageable.getPageSize());

    final Long total = QueryUtils.executeCountQuery(getCountQuery(spec));
    final List<T> content = total > pageable.getOffset() ? query.getResultList() : Collections.<T>emptyList();

    if (total > maximumRecords) {
        return new CustomPageImpl<>(content, pageable, maximumRecords, String.format(ERROR_MESSAGE, maximumRecords));
    } else {
        return new PageImpl<>(content, pageable, total);
    }
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:15,代码来源:CustomSimpleMaxedJpaRepository.java

示例6: getPageQuery

import org.springframework.data.domain.Pageable; //导入方法依赖的package包/类
@Override
public String getPageQuery(Pageable pageable) {
	int offset = pageable.getOffset()+1;
	return generateRowNumSqlQueryWithNesting(getSelectClause(), false, "TMP_ROW_NUM >= "
			+ offset + " AND TMP_ROW_NUM < " + (offset+pageable.getPageSize()));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:7,代码来源:OraclePagingQueryProvider.java

示例7: getPageQuery

import org.springframework.data.domain.Pageable; //导入方法依赖的package包/类
@Override
public String getPageQuery(Pageable pageable) {
	int offset = pageable.getOffset() + 1;
	return generateRowNumSqlQueryWithNesting(getSelectClause(), false,
			"TMP_ROW_NUM BETWEEN " + offset + " AND " + (offset + pageable.getPageSize()));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:7,代码来源:Db2PagingQueryProvider.java

示例8: find

import org.springframework.data.domain.Pageable; //导入方法依赖的package包/类
@Override
public <X> Page<X> find(String hql, String countHql, Map<String, ?> params, Pageable pageable, Class<X> clazz) {
    long total = count(countHql, params);
    List<X> content = total > pageable.getOffset() ? find(hql, params, pageable, clazz) : Lists.newArrayList();
    return new PageImpl<>(content, pageable, total);
}
 
开发者ID:zhaoqilong3031,项目名称:spring-cloud-samples,代码行数:7,代码来源:BaseRepositoryImpl.java

示例9: findByNative

import org.springframework.data.domain.Pageable; //导入方法依赖的package包/类
@Override
public <X> Page<X> findByNative(String sql, String countSql, List<?> params, Pageable pageable, Class<X> clazz) {
    long total = countByNative(countSql, params);
    List<X> content = total > pageable.getOffset() ? findByNative(sql, params, pageable, clazz) : Lists.newArrayList();
    return new PageImpl<>(content, pageable, total);
}
 
开发者ID:zhaoqilong3031,项目名称:spring-cloud-samples,代码行数:7,代码来源:BaseRepositoryImpl.java


注:本文中的org.springframework.data.domain.Pageable.getOffset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。