Re: db based cascade delete

Stéphane Corthésy <[email protected]> Wed, 1 Oct 2003 09:25:09 +0200
Newsgroups gmane.comp.web.webobjects.eof
Message-ID <[email protected]>
Hi,

If you have no validateForDelete in your code and think that you could 
safely delete everything behind EOF's back, then you could issue the 
right SQL and then tell EOF to invalidate all matching objects. Works 
fine when you know what you're doing.

Another possibility, depending on your needs: you could avoid modelling 
the to-many relationships, and create fetchSpecs when you need the B's 
and C's; you'd also need to manage the deletion of B's and C's 
manually, when deleting A's.

Stéphane


On Wednesday, Oct 1, 2003, at 03:44 Europe/Zurich, David Teran wrote:

> Hi,
>
> we have a class hierarchy like this: A->>B->>C and we have cascade 
> deletion from A to B to C. This takes -time- with EOF, i made tests 
> about 1 day for a specific task in a project, way too long. Doing this 
> directly in the db is a question about seconds and i wonder what we 
> have to do in the app. imagine we have fetched all A entities and the 
> fault form relationship to B, the NSArray fired already. Now if we 
> only delete A with
>
> NSArray bs = a.toBs();
> editingContext.deleteObject(a);
> editingContext.saveChanges();
> //at this time b's are already delete in the db.
> B aB = bs.objectAtIndex(0);
> aB.takeValueForKey("aNewValue", "aKey");
> aB.editingContext().saveChanges();
>
> OK, this will throw an exception or at least should because aB does 
> not exist in the db anymore. So is there a simple solution for this 
> situation?
>
> cheers David
>
> _______________________________________________
> EOF mailing list
> [email protected]
> http://www.omnigroup.com/mailman/listinfo/eof
>
--
Stéphane Corthésy
Sen:te, Lausanne, Switzerland            http://www.sente.ch/