Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If your Collection is only used for transforming @Persistent childRealKeys in a transient way, then it should be @NotPersistent childList.</p> <p>In that context:</p> <pre><code>// pm.deletePersistent(detachedParent.getChildList()); becomes unnecessary, and pm.deletePersistent(parent); //should work </code></pre> <p>Are you getting another exception in that case?</p> <p>UPDATE by @jmort253:</p> <p>Checked to be sure there aren't duplicate appengine JAR files included in the project. I upgraded earlier and some of the older JARS weren't removed from the CLASSPATH. The classloader may load the older versions and ignore the newer versions, and this was happening in my case. It turns out that resolving the dependencies takes care of the issue. </p> <p>Additionally, I can then use @NotPersistent without issues, and I can detach the object using a Transaction and the <a href="http://www.datanucleus.org/products/accessplatform/jdo/attach_detach.html" rel="nofollow">PMF DataNucleus DetachOnClose property</a> as <a href="http://groups.google.com/group/google-appengine-java/browse_thread/thread/505704f5db649c1a?fwc=1" rel="nofollow">Andy describes in this Google Group</a>.</p> <p><strong>Deleting Parent</strong>:</p> <pre><code>public boolean deleteLoop(String parentId) { PersistenceManager pm = PMF.getInstance().getPersistenceManager(); Transaction tx = pm.currentTransaction(); try { tx.begin(); pm.setDetachAllOnCommit(true); Parent parent = null; Key parentKey = KeyFactory.stringToKey(parentId); loop = pm.getObjectById(Parent.class, parentKey); Parent detachedParent = pm.detachCopy(parent); // this was indeed not necessary //pm.deletePersistent(detachedParent.getChildList()); // no detachment issues, object deletes just fine. pm.deletePersistent(detachedParent); tx.commit(); //pm.close(); } catch(Exception e) { log.error("Exception trying to delete Parent :: ",e); e.printStackTrace(); } finally { if(tx.isActive()) { tx.rollback(); } pm.close(); } } </code></pre> <p><strong>Parent Class:</strong></p> <p>Can now add @NotPersistent without getting classpath warnings. In addition to the JAR dependency issues, I had to add a parameterized type to the Collection definition. If it's omitted, you get the following warning:</p> <ul> <li><p>Class "" was not found in the CLASSPATH. Please check your specification and your CLASSPATH.</p> <pre><code> @PersistenceCapable(detachable = "true") public class Parent implements Serializable { ... @NotPersistent private Collection&lt;Child&gt; childList; ... } </code></pre></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload