title: Hibernate Session flush behaviour [ and Spring @Transactional ]
body: <p>I use Spring and Hibernate in a web-app,</p>
  
  <p>SessionFactory is injected into a DAO bean, and then this DAO is used in a Servlet through webservicecontext.</p>
  
  <p>DAO methods are transactional, inside one of the methods I use ...    getCurrentSession().save(myObject);</p>
  
  <p>One servlet calls this method with an object passed.</p>
  
  <p><b>The update seems to not be flushed at once</b>, it takes about 5 seconds to see the changes in the database. The servlet's method in which that DAO's update method is called, takes a fraction of second to complete.</p>
  
  <p><em>After the @Transactional method of DAO is completed, flushing may NOT happen ? It does not seem to be a rule</em> [ I already see it ]. </p>
  
  <p>Then the question is this: what to do to force the session to flush after every DAO method?
  It may not be a good thing to do, but talking about a Service layer, some methods must end with immediate flush, and Hibernate Session behavior is not predictable.</p>
  
  <p><b>So what to do to guarantee that my @Transactional method persists all the changes after the last line of that method code?</b></p>
  
  <pre><code> getCurrentSession().flush() is the only solution?
  </code></pre>
  
  <p>p.s. I read somewhere that @Transactional IS ASSOCIATED with a DB Transaction. Method returns, transaction must be committed.
  I do not see this happens. </p>