Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Inspired by @DataNucleus's comments, I have made a work-around in a vaguely similar spirit. The work-around set out below works for me, but I find that my underlying issue remains.</p> <p>All persistent entities that use a (read-only) numeric ID of an encoded key string will need to have their <code>getID()</code> method changing to use the work-around.</p> <p><strong>Java code</strong></p> <p>I amend my ID getter method (given earlier) to as follows:</p> <pre><code>public Long getID() { Long loResult = DataExchange.getIDFromEKSIfIDIsNull(loID, sEncodedKey); return loResult; } </code></pre> <p>My <code>DataExchange</code> class has the new method:</p> <pre><code>import com.google.appengine.api.datastore.Key; import com.google.appengine.api.datastore.KeyFactory; /** * Get the ID supplied, or get it from the encoded key string if the ID is * &lt;code&gt;null&lt;/code&gt;. * &lt;br/&gt; * This method is necessary since JDO version 3.0.1 introduces a long delay * between entity first persistence and ID availability using the DataNucleus * GAE primary key ID plug-in. * @param loID * The persistent entity ID. * This may be &lt;code&gt;null&lt;/code&gt; if the entity has been persisted for the * first time but its generation is delayed (a big hello to JDO version * 3.0.1). * @param sEncodedKey * The persistent entity encoded key string. * This should be not &lt;code&gt;null&lt;/code&gt; if the entity has been persisted. * @return * &lt;ul&gt; * &lt;li&gt; * If the persistent entity ID supplied is not &lt;code&gt;null&lt;/code&gt; * then return it * &lt;/li&gt; * &lt;li&gt; * else if the encoded key string is not &lt;code&gt;null&lt;/code&gt; then extract * the ID and return it * &lt;/li&gt; * &lt;li&gt; * else return &lt;code&gt;null&lt;/code&gt;. * &lt;/li&gt; * &lt;/ul&gt; */ public static Long getIDFromEKSIfIDIsNull(Long loID, String sEncodedKey) { Long loResult = null; if (loID != null) loResult = loID; else if (sEncodedKey != null) { Key key = KeyFactory.stringToKey(sEncodedKey); if (key != null) { long loIDFromEKS = key.getId(); loResult = Long.valueOf(loIDFromEKS); } } return loResult; } </code></pre>
    singulars
    1. This table or related slice is empty.
    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. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    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