How can I implement a method that return a page of objects using JpaRepository and not PagingAndSortingRepository ?
My repository
public interface GroupRepository extends JpaRepository<Group, Long> { @Query(value = "SELECT g FROM Group") Page<Group> listAllByPage(Pageable pageable); } My service implementation:
@Override public Page<Group> findGroupesByPagination(Pageable pageable) { return groupeRepository.listAllByPage(pageable); } My rest Controller method:
@RequestMapping(value="/groups", method = RequestMethod.GET) public @ResponseBody Page<Group> list( Pageable pageable){ Page<Group> groupes = groupeServiceImpl.findGroupesByPagination(pageable); return groupes; } Finally I got this error:
Error creating bean with name 'groupServiceImpl': Unsatisfied dependency expressed through field 'groupeRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'groupRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract org.springframework.data.domain.Page rimtrack.org.repository.GroupRepository.listAllByPage(org.springframework.data.domain.Pageable)!