NoExtent and object references
Hello,
lets have two abstract %Persistent classes A,B with NoExtent keyword (storing data in separate globals for each subclass).
Class A Extends %Persistent [Abstract, NoExtent]
{
}
Class B Extends %Persistent [Abstract, NoExtent]
{
Property Aref As A;
}
Let B class reference the A class. Since the A class has no extent the reference wont work in subclasses. It wont be even usable in SQL. Is it possible to solve this problem? Whats the recommended way to deal with references/relationships using NoExtent?
Why are you using NoExtent here?
I want to keep the data in separate globals for each subclass. Do you have a better way to achieve that?
If you know which non-NoExtent (for lack of a YesExtent keyword :-) ) subclass of A you're targeting in B's subclass, you can override your property definition pointing to that subclass.
You would have to override it in every subclass for every reference property :) that defeats the purpose of defining it in superclass. But yes, you are right.
OK. In your original post, you wrote "storing data in separate globals for each class" which made me ask my question. You should probably edit that to be "storing data in separate globals for each subclass".
And, yes, that is the correct way to achieve that.
If you want to allow subclasses of class A with a property that references Abstract %Persistent Class B, and allow A objects to use that property to reference any of the subclasses of B, class B must have its own extent (all subclass data stored in the same global). Otherwise, since the A objects only store the ID of the referenced B objects, how would the system determine which subclass of B ID #52 refers to? When all the subclass data is stored in the same global, IDs are unique across all subclasses, and ID #52 refers to one object only.
Adding a BitMap extent index to class B helps compensate for the fact that all B objects are stored together, and improves the performance of queries on the subclasses.