title: org.hibernate.exception.SQLGrammarException: could not execute query using scroll
body: <p>I have the following query,
  When I tried to execute it using hibernate I get the following exception :</p>
  
  <blockquote>
    <p>org.hibernate.exception.SQLGrammarException: could not execute query
    using scroll.</p>
  </blockquote>
  
  <p>In my code I have scroll has FORWARD_ONLY.
  Can anyone please provide a perfect solution.</p>
  
  <pre><code>select * from (SELECT account_no    AS accountno,rownum r  FROM  sc_dcm_postpaid_index  WHERE  groupid = 'SBG-2012'  
  and concat(trim(TO_CHAR(bill_date,'MONTH')),concat('-',TO_CHAR(bill_date,'YY')))='JUNE-12'  
  AND ROWID  IN   (SELECT MAX(ROWID) AS row_no   ;   FROM sc_dcm_postpaid_index
  WHERE groupid= 'SBG-2012'  and concat(trim(TO_CHAR(bill_date,'MONTH')),concat('-',TO_CHAR(bill_date,'YY')))='JUNE-12' 
  GROUP BY account_no   HAVING COUNT (account_no) &gt;= 1   ) ORDER BY account_no)where r &gt;= 11  and  r &lt;= 21..
  </code></pre>
  
  <p>Also when I change the query to </p>
  
  <pre><code>SELECT account_no    AS accountno,rownum r  FROM  sc_dcm_postpaid_index  WHERE  rownum &gt;= 11  and  rownum &lt;= 21 groupid = 'SBG-2012'  
  and concat(trim(TO_CHAR(bill_date,'MONTH')),concat('-',TO_CHAR(bill_date,'YY')))='JUNE-12'  
  AND ROWID  IN   (SELECT MAX(ROWID) AS row_no   ;   FROM sc_dcm_postpaid_index
  WHERE groupid= 'SBG-2012'  and concat(trim(TO_CHAR(bill_date,'MONTH')),concat('-',TO_CHAR(bill_date,'YY')))='JUNE-12' 
  GROUP BY account_no   HAVING COUNT (account_no) &gt;= 1   ) ORDER BY account_no
  </code></pre>
  
  <p>And this is my Query:</p>
  
  <pre><code>SQLQuery mainQuery = (SQLQuery) session.createSQLQuery(strReportQuery);
  ScrollableResults itrDataList = mainQuery.scroll(ScrollMode.FORWARD_ONLY);
  </code></pre>
  
  <p>Here <code>strReportQuery</code> is my query</p>
  
  <p>It executes fine but it works only from rownum 1 to 10.
  From next rownum it gives resultset as empty.</p>
  
  <p>Thanks in Advance,
  Bhargavi T.</p>