title: How to paginate a JPA Query
body: <p>I have a submission table with columns like <code>ID</code>, <code>Name</code>, <code>Code</code> among other properties. My requirement is to search for records based on the mentioned properties and return a paginated set.</p>
  
  <p>This is the pseudocode for what I am looking for:</p>
  
  <pre><code>searchSubmission(searchFilter sf,pageIndex,noOfRecords) {
     query = 'from submisssion where code=sf.code or id=sf.id order by id start_from (pageIndex*noOfRecords) limit noOfRecords'
     return result();
  }
  </code></pre>
  
  <p>There seem to be many options like <code>CriteriaBuilder</code>, <code>NamedQuery</code>, etc. Which is the most efficient one in this situation?</p>