title: Spring JPA: What is the cost of saveandflush vs save?
body: <p>I have an application built from a set of microservices.  One service receives data, persists it via Spring JPA and Eclipse link and then sends an alert (AMQP) to a second service.  </p>
  
  <p>Based on specific conditions, the second service then calls a RESTfull web service against the persisted data to retrieve the saved information.  </p>
  
  <p>I have noticed that sometimes the RESTfull service returns a null data set even though the data has been previously saved.  Looking at the code for the persisting service, <em>save</em> has been used instead of <em>saveandflush</em> so I assume that data is not being flushed fast enough for the downstream service to query.  </p>
  
  <ul>
  <li>Is there are cost with saveandflush that I should be weary of or should is it reasonable to use it by default?  </li>
  <li>Would it ensure immediacy of data availability to downstream applications?  </li>
  </ul>
  
  <p>I should say that the original persistence function is wrapped in <code>@Transactional</code></p>