I want to return "ownDemand" as Page of demand. How can I do that
@Override
public Page<Demand> getDemandbyId(Long id, Pageable pageable) {
Iterable<Demand> alldemand = demandRepository.findAll();
List<Demand> ownDemand = new ArrayList<Demand>();
for (Demand demand : alldemand) {
if(demand.getStore().getId()==id) {
ownDemand.add(demand);
}
}
return null;
}
}
Demand Repository
@RestResource
public interface DemandRepository extends JpaRepository<Demand,Long> {
}
Why not add a method to your DemandRepository like so
Page<Demand> findAllByStore(Store store, Pageable page)
This assumes that StoreEntity is related to Demand, of course.