title: Performance problems using JPA
body: <p>I am using JPA in my web application (hibernate is the vendor) and I am confused regarding performance of queries.
  In my code I use the following query:</p>
  
  <pre><code>select c.id from Cdr c where c.receivedOn &gt;= :start and c.receivedOn &lt; :end and c.buy.id in (:buyList)
  </code></pre>
  
  <p>Running this query against the DB directly takes 0.1 seconds to execute.
  Running this through the server takes a few minutes, what am I missing here?</p>
  
  <p>here is the query generated by the java:</p>
  
  <pre><code>select cdr0_.id as col_0_0_ from billing_cdr cdr0_ where cdr0_.received_on&gt;=? and cdr0_.received_on&lt;? and (cdr0_.buy_id in (? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ?))
  </code></pre>