[Lazarus] [OT] How to delete a record/object being used
Joao Morais
post at joaomorais.com.br
Tue Sep 9 18:44:21 CEST 2008
Graeme Geldenhuys wrote:
> On 9/9/08, Michael Van Canneyt <michael at freepascal.org> wrote:
>> When you delete AdresType record with ID 1, all ADDRESSES records that have
>> AddressType =1 will automatically be deleted.
>
> OK, now the big question which might affect you as well. How do you
> translate this to tiOPF based applications? What if you delete an
> AddressType from the database (with cascade delete), but still have
> some objects (Contacts) in memory. They wouldn't know about the
> cascade delete. In tiOPF it's the Object that requests a delete and
> only for that specific object. A cascade delete can delete a lot of
> objects/records, not just itself. I guess some delete visitor would
> have to be launched as well on any loaded (in memory) objects.
You shouldn't have such problem. Cascade deletes happens only with
compositions. A composed object is never disposed by itself, but ony
through its owner. On the other hand, an aggregated object should never
be disposed by other objects, and when it is disposed, the others that
reference it should say 'you cannot', stop the process and raise an
exception.
Joao Morais
More information about the Lazarus
mailing list