Re: Custom keys and models with objectIdClass, cause an exception when quering using mongo
I can run an abstract base class + concrete subclass with a basic own definition of PK, and then persist an object (of the concrete type), and then call getObjectById using that PK (with it doing a database call). It works (with MongoDB, and also with RDBMS, and likely any other datastores).
Consequently you should look at your code, and run the same thing but without your PK class (i.e using the built-in PK classes) and see what happens.
Then just create a very simple own definition of PK class (as the `objectIdClass`) ... as per the example in the docs ... and see if that works. If it does work then your PK class is the problem.
A "second class type" is defined in the docs and the JDO spec.
FWIW `targetClassName` is a special field name for PK classes, defined in the DN 5.1 documentation (search the Mapping Guide). This will store the fully-qualified type name of the object that it represents. If you want to store something other than that, you should use a different field name.
It is fairly safe to conclude that if something works with RDBMS then you should NOT be considering changing ANY code in `datanucleus-core` just to get some minority case on MongoDB to work (if that indeed ends up as the conclusion).