Note that there are some explanatory texts on larger screens.

plurals
  1. POmakePersistent for owned one-to-many rs. not working reliably in JDO
    text
    copied!<p>the makePersistent method of the PersistenceManager is not working reliably. one and the same junit-test is working and after a while its failing again?! i have an object that includes a collection of other objects. that means an 1-n relationship. my problem is that the junit-test of my classes is failing sometimes because the objects in the collection are not persisted properly. i am using usually transactions but the persistanceManager is transaction-optional</p> <p>i tried checking the objectState after each createObject and commit... i figured out that the objects in the collection after a successful commit have no systemId (should be auto-generated) but are in state hollow/persistent-nontransactional.</p> <p>that means sometimes they are (if they are persisted):</p> <p><em>Comment [systemId=Project(1)/Comment(6), JDO-ObjectState=hollow/persistent-nontransactional]</em></p> <p>and sometimes they are (if they are not persisted and a refach of the parent-object contains an empty collection) <em>Comment [systemId=null, JDO-ObjectState=hollow/persistent-nontransactional]</em></p> <p>off course i could check manually if all the stored objects have an systemId but this approach is not nice at all. the commit should just fail!!</p> <p>i do not understand that it is sometimes working and sometimes not! that means my code should not be wrong and this is a bug... pls help me out</p> <p>PS: i can post some code if necessary!</p> <pre><code>@PersistenceCapable public class Ble implements Serializable, JDOObject&lt;Ble&gt; { /** * */ private static final long serialVersionUID = 1L; // NotNull @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key systemId; // NotNull @Persistent private Key parentId; // NotNull @Persistent @Extension(vendorName = "datanucleus", key = "gae.parent-pk", value = "true") private Key projectId; // NotNull @Persistent private String title; @Persistent private int position; @Persistent private boolean hasChildren; @Persistent private BleData requirementData; @Persistent private List&lt;Comment&gt; comments; //getter/setter } </code></pre> <p>childObject</p> <pre><code> @PersistenceCapable public class Comment implements Serializable, JDOObject&lt;Comment&gt; { /** * */ private static final long serialVersionUID = 1L; @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key systemId; @Persistent private String text; @Persistent private long createdTimestamp; //getter//Setter } </code></pre>
 

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