title: JDO - Do I need to call DetachCopy on my model object before passing it to a view?
body: <p>My understanding of detach copy is that it makes a copy of your object so that you can make changes to it without the PersistenceManager noticing.</p>
  
  <p>Since I close my PersistenceManager before passing the model object to the view to be used, I wouldn't have to call anything like detachCopy or makeTransient before passing it along would I?</p>
  
  <p>The examples I looked at do call it though...
  This is the example I looked at from <a href="http://code.google.com/appengine/docs/java/datastore/creatinggettinganddeletingdata.html" rel="nofollow noreferrer">http://code.google.com/appengine/docs/java/datastore/creatinggettinganddeletingdata.html</a>:</p>
  
  <pre><code>public Employee getEmployee(User user) {
      PersistenceManager pm = PMF.get().getPersistenceManager();
      Employee employee, detached = null;
      try {
          employee = pm.getObjectById(Employee.class,
              "Alfred.Smith@example.com");
  
          // If you're using transactions, you can call
          // pm.setDetachAllOnCommit(true) before committing to automatically
          // detach all objects without calls to detachCopy or detachCopyAll.
          detached = pm.detachCopy(employee);
      } finally {
          pm.close();
      }
      return detached;
  }
  </code></pre>