title: Doctrine2 - the entity loaded for session doesn't work
body: <p>I use Doctrine2 in my ZendFramework project and I've got a not easy to resolve for me a problem...</p>
  
  <p>So, when user has successfully log in to the page, I put his object into the session:</p>
  
  <pre><code>Zend_Auth::getInstance()-&gt;getStorage()-&gt;write($user);
  </code></pre>
  
  <p>Everything works fine, but when I refresh the page and load an user from session:</p>
  
  <pre><code>$user = Zend_Auth::getInstance()-&gt;getStorage()-&gt;read();
  </code></pre>
  
  <p>And with this $user I can't do any Doctrine2 operations :-/. I'm able to use for example "getId()" method, but when I try for example use $user in any relations:</p>
  
  <pre><code>$session = new App_Model_LogSessions();
  $session-&gt;setUser($user);
  ...
  </code></pre>
  
  <p>I see the Doctrine2 exception:</p>
  
  <blockquote>
    <p>Entity App_Model_Users is not managed. An entity is managed if its fetched from the database or registered as new through EntityManager#persist</p>
  </blockquote>
  
  <p>How can I fix this? Is there any method to "reload" the entity? I need to use the session, I don't want to load user from database in every page request. I'd like to load him once and put him to the session.</p>
  
  <p>Thanks!</p>