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.
Comments
ClassReference of %Library.Persistent shows it as sub classes
http://docs.intersystems.com/latest/csp/documatic/%25CSP.Documatic.cls?…

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?
SELECT cd.name FROM %Dictionary.ClassDefinition cd JOIN subclassofquery sq ON sq.Name = cd.Name WHERE cd.System IS NULL
high comfort service ! ![]()
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.