CM Wang · Aug 15, 2017

How to get all the names of the classes which inherits %Persistent

I want to retrieve all the names of classes which are %Persistent in a namespace by COS.

Any suggestion, Thanks.

0 637
Discussion (8)1
Log in or sign up to continue

Programmatically you can use the SubclassOf() query in the %Dictionary.ClassDefinitionQuery class. Pass in %Persistent and the flag for non-system classes.

It seems like any classes defined in %SYS would also returned by this method.

Any way to filter them out? Thanks.

You could then iterate through the returned classes and check to see which ones are marked "system" by opening up each definition. I seem to vaguely remember a way to do this with a query but I can't find it now.

SQL join or is there something more elaborate?

FROM %Dictionary.ClassDefinition cd
JOIN subclassofquery sq ON sq.Name = cd.Name

SYSTEM is not a valid filter. That keyword allows the class compiler to organize classes into compile 'groups' so that a class that may depend on another class at compile time is guaranteed to have the dependency resolved.

It isn't an indicator that the class originated in %SYS/%CACHELIB.

I have just posted an article here about how to determine whether a class is mapped.