title: How to de-serialize an entity, put it in managed context, but not persist any changes?
body: <p>I'm new to persistence and I want to do the following:</p>
  
  <p>1) Load a part of database into entities and store them in a file</p>
  
  <p>2) Load these entities from file, put them in managed context (so that all the @JoinColumn and @JoinTable, especially those with lazy fetch type, would work normally) and make sure that I don't accidentally update database with them.</p>
  
  <p>The point of all that is that every time I start the application I don't want to call database for the table that almost never change - so I want to store them locally, preferably in a file.</p>
  
  <p>While part 1) was pretty easy, I have some concerns as to part 2). I figured that loadObject and em.persist() would work fine as long as I make sure not to call em.flush(). </p>
  
  <p>But at one point I'd like to check if the object in database hasn't been changed. If I call persist() on my de-serialized entity, and at the same time database changed, after flushing which version would remain?</p>
  
  <p>Is there a better way to do this?</p>