Imagine a master-detail situation with the entities:
TMaster having:
[ManyValuedAssociation([TAssociationProp.Lazy], CascadeTypeAll, 'fMaster')]
fDetails: Proxy<TList<TDetail>>;
TDetail having:
[Association([TAssociationProp.Lazy], [])]
[JoinColumn('ID_MASTER', [])]
fMaster: Proxy<TMaster>;
and
constructor TMaster.Create;
begin
inherited Create;
fDetails.SetInitialValue(TList<TDetail>.Create);
end;
destructor TMaster.Destroy;
begin
fDetails.DestroyValue;
inherited Destroy;
end;
This way of creating/destroying fDetails will not free TDetail instances, resulting in memory leaks.
I think the best way forward would be to declare fDetails as a TObjectList<TDetail> owning the detail instanced.
My question:
a) what would be the best approach to avoid leaks? Anything that Aurelius does to help?
b) what if the entity-model is rather complex with N-M relations between the details of different master-detail sets?
Appreciate your inputs!