[Opensource] Cascading Deletes

Michael Rimov rimovm at centercomp.com
Mon Dec 9 11:08:18 PST 2002


At 03:38 PM 12/9/2002 +0000, you wrote:
>Hi,
>
>I have a DBObject for which I've overridden the checkAllReferredToBy()
>method to trap any deletes of rows with foreign key references and return a
>meaningful message to the user.  This DBObject itself has a 'parent'
>DBObject, and I've set up the relationship using addDetail().  When I
>attempt to delete a 'parent' row I was expecting each detail's
>checkAllReferredToBy() method to be called, but I notice that when doing
>cascading deletes the deleteAll() method is used which bypasses this check.
>Am I missing something obvious?
>I'm using Expresso 5.01.

Hi Malcolm!

Actually Mike N. originally implemented it this way [meaning deleteAll()] 
for performance reasons in dealing with master/detail recordsets.  I 
suspect, however, that as far as I see Expresso going in the future, it 
would only continue this way since my ideal would be to have Cascade 
Deletes set up automatically for various databases.

As far as a better CheckAllReferredtoBy() so that it at least gets called, 
to be honest, we need a better 'event bus' in that dbobject listeners are 
fine, but we have to decide which instance we're going to notify..... [I 
think I'm babbling here]

I'd suggest overriding the delete() method in your "master" object to get 
your desired behavior.

HTH!
                                                 -Mike





More information about the Opensource mailing list