jpa条件查询和分页

public Page getpage(final Integer id, int page, int size) {
		Pageable pageable = new PageRequest(page, size, new Sort("id"));
		Specification spec = new Specification() {

			public Predicate toPredicate(Root root,
					CriteriaQuery query, CriteriaBuilder cb) {
				return query.where(cb.lt(root.get("id").as(Integer.class), id))
						.getRestriction();
			}
		};
		return studentDao.findAll(spec, pageable);
	}
这里需要有criteria基础

你可能感兴趣的:(JPA,一句话总结)