title: Spring boot jpa select millions of records from db and process the data
body: <p>I am working on a spring boot application where I need to fetch 400000 rows from db and pass it on as a list.</p>
  
  <p>How should i approach this?</p>
  
  <p>I am thinking of a way to split the records in groups of 1000 and pass it on.</p>
  
  <p>But in that case how will I specify the offset in my sql query, like once I fetch first 1000 records how to fetch 1001 - 2000 records?</p>
  
  <p>Another way is if I can fetch the records as a stream, in that case I have to find a way in which I can send the stream through a REST GET api from my application whenever someone calls my api.</p>
  
  <p>Basically I need to build a rest get api where I need to pass this data to who ever is using my api</p>