title: Hibernate prepared statement is replacing values with question mark
body: <p>We are using Hibernate 3 with WebSphere v6 and DB2. We are having strange issue with wrong SQL prepared statements issued by Hibernate and causing syntax issues. </p>
  
  <p>Good query issued by Hibernate:</p>
  
  <blockquote>
    <p>SELECT * FROM rocc.Transaction t WHERE t.status_cd = 0 and
    t.application_cd = ? order by coalesce(t.priority,0) fetch first 25
    rows only</p>
  </blockquote>
  
  <p>Same query issued by Hibernate incorrectly sometimes:</p>
  
  <blockquote>
    <p>SELECT * FROM rocc.Transaction t WHERE t.status_cd = <strong><em>?</em></strong> <em><strong>AND</em></strong>
    t.application_cd = ? <strong><em>ORDER BY COALESCE</em></strong>(t.priority,<strong><em>?</em></strong>) <strong><em>FETCH</em></strong> first
    <strong><em>?</em></strong> <em><strong>ROWS ONLY</em></strong></p>
  </blockquote>
  
  <p>It is replacing values(zero) with question mark and changing font of the keywords to uppercase (it does not matter, but mentioning here). It also changed the number 25 in fetch clause with question mark.</p>
  
  <p>What is causing with the wrong prepared statement issued by Hibernate sometimes?</p>
  
  <p>Hibernate is calling WSJdbcPreparedStament.executeQuery method.</p>