PersistentClassROF#getObject method performs a shallow search so not finding all subclasses


Page bloom
 
Edited

We've noticed a problem where, during object retrieval of an object with a class that is 2 levels derived from an abstract base class, DN displays the message:

[WARN ] 05:33:20.915 Retrieve - Found type=class com.sas.framework.BlahBlah but abstract and more than 1 concrete subclass ([com.sas.BlahLevel1Cls1, com.sas.BlahLevel1Cls2, com.sas.BlahLevel1Cls3]). Really you need a discriminator to help identifying the type. Choosing class com.sas.BlahLevel1Cls3

This was unexpected because:
  • A discriminator is configured in the abstract base class
  • A discriminator value is provided in each of the derived classes
  • The list of concrete subclasses is only a small subset of the classes in the model
  • It is only showing the list of subclasses immediately extending the abstract base class
Looking at PersistentClassROF#getObject we noticed that the call to getSubclassesForClass passes 'false' for the 'includeDescendants' parameter - which would prevent it from finding subclasses beyond the classes that immediately extend the abstract base class.

            String[] subclasses = this.ec.getMetaDataManager().getSubclassesForClass(pcClassForObject.getName(), false);
 
 Is this intentional? How will it ever find the other classes 

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