title: Pagination is not working when calling MySQL Stored Procedure using Hibernate
body: <p>I have a MySQL Stored Procedure <a href="https://stackoverflow.com/questions/14352987/how-to-write-hibernate-mapping-file-for-a-stored-procedure">click here for stored procedure</a> and calling the Procedure using Hibernate </p>
  
  <p>Hibernate Code:</p>
  
  <pre><code>int ps=5;
  
      SQLQuery query=session2.createSQLQuery("CALL AbsentReportproc(:_fromdate,:_todate)");
              query.setParameter("_fromdate", fromdate);
              query.setParameter("_todate", todate);
              query.setFirstResult(ps*(pno-1));
              query.setMaxResults(ps);
               List&lt;Object[]&gt; empList=query.list();
  </code></pre>
  
  <p>when I execute above code I'm displayed with the following Error Message:</p>
  
  <pre><code>org.hibernate.exception.SQLGrammarException: could not execute query
  Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'limit 5' at line 1
  </code></pre>
  
  <p><strong>Note:If i remove the below statement from the code,I'm displayed with all records in a single jsp Page</strong></p>
  
  <p><strong>query.setMaxResults(ps);</strong></p>
  
  <p>Could any one give me the solution what was the Problem?</p>
  
  <p>thanks...</p>