title: Is Hibernate flush() synchronous or asynchronous?
body: <p>I am doing some test in which the flush and clear is not visible inmediately. Waiting for Hibernate to make the flush solves the problem.  Does it means that flush is asynchronous? Is there any official Hibernate documentatio about it?</p>
  
  <p>This fails:</p>
  
  <pre><code>@Test
  public void doTest()
     Entity oldData = myDAO.load(1L);
     oldData.setField("foo");
  
     myDAO.update( oldData);     
     flushAndClear();
  
     oldData= myDAO.load(oldData.getId()); // Reload
     assertThat(oldData.getField() , notNullValue());
  }
  </code></pre>
  
  <p>But this works:</p>
  
  <pre><code>@Test
  public void doTest()
     Entity oldData = myDAO.load(1L);
     oldData.setField("foo");
  
     myDAO.update( oldData);      
     flushAndClear();
  
     Thread.sleep(1000);  /** WAITING SOME TIME*/
     oldData= myDAO.load(oldData.getId()); // Reload
     assertThat(oldData.getField() , notNullValue());    
  }
  </code></pre>
  
  <p>flushAndClear is just:</p>
  
  <pre><code>getCurrentSession().flush();
  getCurrentSession().clear();
  </code></pre>