title: EntityManager. Does Flush() save data in database as Commit()?
body: <p>I have already looked through a number of topics about <strong>entityManager.flush()</strong> method. 
  In my practice I always have used <em>persist()</em> and <em>commit()</em> methods. </p>
  
  <p>Also I have found that sometimes <em>flush()</em> automatically executes during <em>select</em> request to database and at this point it checks for example constraints of database so if persisted objects is wrong due to constraints during <em>select</em> an exception will be thrown. </p>
  
  <p>Actually I would like to understand:</p>
  
  <ol>
  <li><p>When you do <em>flush()</em> method then does a persisted data become saved in database? So you don't need to do <em>commit()</em> after <em>flush()</em>?</p></li>
  <li><p>What is the advantages of using <em>flush()</em> instead of <em>commit()</em>, may be in some concrete cases? </p></li>
  </ol>