When I make a class that defines both "gae.encoded-pk" and "gae.pk-id" persistent, the encoded-pk is updated, but the id remains null. There's no exception being thrown and the code is a straight copy paste from google's documentation, so I'm at a loss as to what may be happening here.
The class defines:
@PersistenceCapable
public class MyClass {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
@Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
private String encodedKey;
@Persistent
@Extension(vendorName="datanucleus", key="gae.pk-id", value="true")
private Long keyId;
And I make it persistent like this:
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
pm.makePersistent(myInstance);
// myInstance = pm.makePersistent(myInstance); - Produces the same result.
} finally {
pm.close();
}
I'm using the debugger to step through this code, but the keyId remains null, even after the persistence manager is closed.
I should also point out that this is running locally using the google appengine development kit. Any pointers as to how I could debug this would be greatly appreciated!
I found this answer:
The GAE JDO plugin only ever sets a "gae.pk-id"/"gae.pk-name" field when it reads in a field marked with that from the datastore (just do a search in SVN trunk, FetchFieldManager is the only place where it's loaded - it doesn't set it when it does a PUT). No idea what it did in 1.x, but all of GAE's own tests pass in 2.x as they did in 1.x. But then that "feature" isn't standard JDO anyway, so of little interest to me.
See: Unable to get ID of newly-created JDO persistent entity using GAE/J DataNucleus plug-in version 2.1.2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With