Search code examples
intersystems-cacheobjectscript

Inherited Relationship not working as expected


I have the following classes:

Class SearchTemplateDO [ Abstract ]
{
 Relationship QueryParts As QueryPartDO [ Cardinality = many, Inverse = SearchTemplate ];
}

Class MyCustomSearchDO Extends (%Persistent, SearchTemplateDO)
{
 /// inherits all properties / relationships from SearchTemplateDO
}

Class QueryPartDO Extends %Persistent
{
   ...

    Relationship SearchTemplate As SearchTemplateDO 
     [ Cardinality = one, Inverse = QueryParts ];

    Index SearchTemplateIndex On SearchTemplate;
}

When I look at these two tables in SQL I see that QueryPartDO's SearchTemplate field is empty and when I look at MyCustomSearchDO I do not see a "QueryParts" field, although both tables have data


Solution

  • In the end I was able to get this to work by extending %Persistent on the abstract class. Before when I tried it, nothing was working and I kept getting a strange error. However, I tried this in a sample project and now it works.