title: Hibernate HQL setMaxResults does not work?
body: <p>I'm building a small program in Java Hibernate handling a subpart of the DBLP database (parsed from XML into a SQL db).</p>
  
  <p>I've queries manipulating big chuncks of data so I want to limit the output result to 10 so it goes faster.</p>
  
  <pre><code>Query query = this.session.createQuery("select A.author_id "
                  + "from publication as P "
                  + "join P.authors as A "
                  + "where P.year &lt;= 2010 and P.year &gt;= 2008 "
                  + "group by A.author_id "
                  + "having count(distinct P.year) = 3");
          query.setMaxResults(10);
          this.authors = query.iterate();
  </code></pre>
  
  <p>That piece of code is supposed to retrieve all the authors who published at least once every year between 2008 and 2010 included.</p>
  
  <p>My problem is that the line "query.setMaxResults(10);" simply does not have effect, the SQL command generated by Hibernate is</p>
  
  <pre><code>select author2_.Author_id as col_0_0_ from publication publicatio0_ inner join author_publication authors1_ on publicatio0_.Publication_ID=authors1_.publication_id inner join author author2_ on authors1_.author_id=author2_.Author_id where publicatio0_.Year&lt;=2010 and publicatio0_.Year&gt;=2008 group by author2_.Author_id having count(distinct publicatio0_.Year)=3
   limit ?
  </code></pre>
  
  <p>Remarque the "limit ?" at the end.</p>
  
  <p>So my question is simple, how do I use properly setMaxResults to get a correct SQL Limit ?</p>
  
  <p>EDIT: all the limit stuff works fine, I misunderstood the use of limit in SQL, what I'm looking for is a way to stop the execution of the query after a given number of rows corresponding to the conditions is found, so that it does not take days to get thousands useless rows but simply returns the 10 first found rows for example.</p>
  
  <p>Thanks in advance !</p>