title: Hibernate Query runs slow in the system, but fast when run directly
body: <p>I have a problem similar to the on in this weeks podcast.</p>
  
  <p>We have a Java application using hibernate with Sql Server 2005.</p>
  
  <p>Hibernate is generating a Query for us that is taking nearly 20 minutes to complete.</p>
  
  <p>If we take the same query using show_sql and replace the questions marks with constant value the answer is returned immediately.</p>
  
  <p>I think we need option(recompile), but I can't figure out how to do that with HQL.</p>
  
  <p>Please help!</p>