title: Hibernate OGM Mongodb Aggregate Query not working with JPA setFirstResult and setMaxResult while next Execution
body: <blockquote>
    <p>I am using Hibernate OGM (5.2.0.Alpha1) with MongoDB (3.4)</p>
  </blockquote>
  
  <p>While I am Executing </p>
  
  <p><strong>String query ="db.student.find({'collegeName' :'VNSGU'})"</strong></p>
  
  <p>for pagination With JPA setFirstResult() and setMaxResult(), It is working fine, but while executing aggregate Query</p>
  
  <p><strong>String query = "db.student.aggregate([{'$match' : {'collegeName' :'VNSGU'}}])";</strong></p>
  
  <p>List listOfStudent = entityManager.createNativeQuery(query, Student.class).setFirstResult(startPosition).setMaxResults(noOfRecords).getResultList();</p>
  
  <p>Execution : </p>
  
  <ul>
  <li><p>In database table, i have total 10 number of records where college name is 
  'VNSGU',</p></li>
  <li><p>When startPosition = 0  and noOfRecords = 5, it will give my proper output on 
  first execution and return 5 records,</p></li>
  <li><p>And when try to execute query second time where startPosition = 5 and 
  noOfRecords = 5, it will return empty list, because on second execution it 
  will have total 5 no of records which is an output of first Execution (i checked 
  it by executing query without setFirstResult() and setMaxResult() and returning 
  total 5 records).As Per, I understood the output of earlier execution will 
  become an input of next execution and it will return result from earlier 
  result.</p></li>
  </ul>
  
  <p>But actually what is happening and What is the solution for this..??</p>