title: How does setMaxResults(N) in Hibernate work?
body: <p>I am using MS SQL server 2008 with Hibernate. the question I have is how Hibernate implements <code>setMaxResults</code></p>
  
  <p>Take the following simple scenario. </p>
  
  <p>If I have a query that returns 100 rows and if I pass 1 to <code>setMaxResults</code>, will this affect the returned result from the SQL server itself(as if running a <code>select top 1</code> statement) or does Hibernate get all the results first (all 100 rows in this case) and pick the top one itself?  </p>
  
  <p>Reason I am asking is that it would have a huge performance issue when the number of rows starts to grow. </p>
  
  <p>Thank you. </p>