title: Poor performance using Hibernate Criteria API
body: <p>I have a Java application using Hibernate to communicate with a MsSQL 2005 server, the driver is <code>net.sourceforge.jtds 1.2.4.</code></p>
  
  <p>Things are working but the performance is <strong>horrible</strong>, I suspect the index isn't used for the queries passed to it, since the response times are proportional to the number of entries in the table.</p>
  
  <hr>
  
  <p>I have written a small test application that use the same driver (jtds) but doesn't use Hibernate and I have been able to reproduce the poor performance (or so I believe). When I use a prepared statements I see the same poor performance as using Hibernate (response times of ~1s), but when I don't the performance is great (~10ms).</p>
  
  <p>I am able to get the same good performance using the <code>Hibernate executeSql</code> method instead of the <code>Criteria</code> interface, but I want to avoid this since I want the code to stay modular and also the results are not converted to my entity class.</p>
  
  <p>Is there some way to have the good performance with Hibernate, while still using a backend-agnostic way of making queries and having the results converted to entity class objects?</p>