I know how to do that with regular classes, but since Aurelius does RTTI stuff I dont know what to do...
the problem is this:
UnitA
uses UnitB;
type tclassA = FClassB:
TClassB; end;
---------------------------- UnitB
uses
UnitC;
type tclassB = FClassC: TClassC;
end;
---------------------------- UnitC
uses UnitA;
<------------- back to beginning
type tclassC =
FClassA: TClassA; end;
It is circular because it comes back on the 3rd unit.
The problem came up on my TEntityItem that has a List of TEntityComposicao that has a List of TEntityComposicaoItems and that has a List of TEntityItem;
I thought the compiler would handle that since it was not a deadlock with 2 units, that it could resolve with 3.
What is the solution based on Aurelius for that? Did you have any case like that?
A way to solve circular references is to go for a base class.
instead TList<TEntityItem> i could use TList<TObject>
and in the IMPLEMENTATION I reference the use of my unit with TEntityItem and in the code use typecast.
That works for the circular reference. WHAT I DONT KNOW and it is real reason of my questions, is what it will looks like for Aurelius since it uses RTTI to read the class definition...
That will not work with Aurelius since it relies on compile-time information about types. Even for Delphi usage, that's a kludge. A best approach would be having a TBaseEntityItem declared in a separate unit and then having TEntityItem inherit from it, and declaring the list as TBaseEntityItem.
You have to put all attributes in the class that is going to be mapped (the actual Aurelius entity). So, you should:
1. Declare your TBaseEntityItem
2. Add the common properties to TBaseEntityItem that you are going to use in your Delphi code only. (I mean, for your code to work fine, the properties that make sense to put in TBaseEntityItem
3. Create TEntityItem inheriting from TBaseEntityItem, and put ALL mapping attributes in it. This way the classes will behave as a hierarchy in Delphi code, but for Aurelius, only TEntityItem exists and will be persisted.