title: Why my is EntityManager fetching outdated database object
body: <p>Situation:</p>
  
  <ul>
  <li>App A (war running on a tomcat 7, rest interface for a web app)</li>
  <li>App B (java standalone, scheduled batch jobs loading data from a file into a database)</li>
  <li>In between a shared control table with a record per file.</li>
  <li>App A correctly persists new record in the control table and sets appropriate state (pending), signalling App B to start processing.</li>
  <li>Web app correctly displays the state as pending.</li>
  <li>App B processes that batch, loads the data and correctly sets new state (processed) signalling the load has been completed. This is easily verified by simple query with fx Squirrel.</li>
  <li>When refreshing the page in the web app the state is incorrectly displayed as pending instead of the correct state: processed. When debugging the response, the state variable is assigned pending. My logs indicate the query taking place on the refresh.</li>
  <li>If I reboot my Tomcat the next query will show the correct result, i.e the state as processed. This also puzzles me, what besides EntityManager is maintaining the database object??</li>
  </ul>
  
  <p>Problem: 
  I just cannot figure out why App A continues to see the state as pending. I've already tried a number of things to ensure that the entityManager has it's cache cleared (both for App A and App B) but still App A queries end up getting the wrong state. </p>