Re: Trouble understanding how to lookup objects that have a Datastore Identity by their PK (if the PK is not identified in the model)


Andy
 
Edited

Use of implementation-specific classes is always a bad idea IMHO. Imagine hardcoding Kodo-specific stuff and then finding that you need to change provider some time later ...

In the same way, reliance on things outside the JDO spec can be problematic.

You could do something like
MyClass myObj = pm.getObjectById(MyClass.class, theIdValue);
This would likely work whether you are using (single-field) application identity OR datastore identity. And you don't need to cast anything ...
I did add an enhancement to datanucleus-core for datastore-id newObjectId, so whether it needs that only you can find out

Join main@datanucleus.groups.io to automatically receive all group messages.