i am using spring data's Pageable to Limit the record fetch. i have more than 500 entries in database but i want to fetch only 5 but it not returning correctly .mostly it return 2,3 or 4 records (every time it return less than 5 record but i have 500 in database).so please help me .code for service class and repository given below
Service code :
public List<Client> listAll() {
Pageable pageable = new PageRequest(0,5);
return (List<Client>) clientRepository.getAllClient(pageable);
}
Repository code :
public interface ClientRepository extends CrudRepository<Client, Long> {
@Query("Select distinct p FROM Client p LEFT JOIN FETCH p.offices LEFT JOIN FETCH p.users LEFT JOIN FETCH p.firmSeats")
public List<Client> getAllClient(Pageable page);
}