title: java web application caching data, how to stop it so that the data is not stale!
body: <p>HI, I am having a problem. My (i am guessing) persistence layer is caching my results, so when i update the database from outside my application then the data is remaining stale. </p>
  
  <p>however, it is only caching half the time, i hope this makes sense,</p>
  
  <p>I have a class</p>
  
  <pre><code>@Entity
  @Table(name = "PROVINCE")
  public class Province implements Serializable {
  
  @Id
  @GeneratedValue
  int id;
  
  String provinceName;
  
  String provinceMoto;
  
  
  Buildings buildings;
  
  
  Units units;
  
  
  Person person;
  
  .... etc
  </code></pre>
  
  <p>now, if i update any data that isn't an a reference to a class object, like the 'provincename' then the data is fine in my application and updates straight away. however, the inner objects like 'buildings' doesn't and i cannot figure out how to, if i do a hard refresh like redeploying my app, then the data is fresh.</p>
  
  <p>i get my province from the database here:</p>
  
  <pre><code>Query query = manager.createQuery("select p from Province p where p.person = :query");
          query.setHint("toplink.refresh", "true");
          query.setParameter("query", p);
  
          province = (Province) query.getSingleResult();
  </code></pre>
  
  <p>so how do i go about forcing that to also make the inner objects of that class, i.e. the 'buildings' 'person' to also update. </p>
  
  <p>my persistence layer is toplink essentials, and i fixed my earlier problem which was no data updating. and that first post <a href="https://stackoverflow.com/questions/4776412/problem-with-updating-application-with-new-data-from-database">here(it's another stack overflow page)</a></p>
  
  <p>thank yous for any helps. i hope i explained my problem well enough</p>
  
  <p>[EDIT: like if i wasnt using this framework, it'd just be easier to join the tables in the db and repopulate the data in a new variable, but im not]</p>