title: IDLE in transaction when using entity manager flush
body: <p>We are using hiberante,c3p0, postgresql for the persistent layer.
  While running data intensive jobs, mostly select/insert, one of the developers decided to use entityManager.flush() before commit , like so</p>
  
  <pre><code>entityManager.getTransaction().begin()
  insert n elements
  entityManager.flush()
  entityManager.getTransaction().commit()
  </code></pre>
  
  <p>After a while all of the threads running the data intensive jobs were seemingly blocked, and we discovered they were waiting on database connections form the pool.
  All the connections on the pool where in "Idle in transaction" state.
  The situation could be replicated every time.</p>
  
  <p>After removing flush() the situation disappeared.</p>
  
  <p>Does anyone have any idea why would this happen?</p>
  
  <p>Thanks :D</p>