But it has to fetch them first to check *their* delete rules, which to prevent was the whole idea.

But my question was why you put together SQL. Take a look at ERXEOAccessUtilities.deleteRowsDescribedByQualifier() to say how this is done right. And no matter how you look at it: manually putting SQL together with Strings is *seriously* wrong. This is 2009, not 1992.

Cheers, Anjo

Am 02.12.2009 um 00:49 schrieb Cheong Hee Ng:

Hi

I think it will be easier to do it from Cascade Delete Rule (define at EOModeler). Such as: organization ->>departments ->> users ->> projects ->> projectStatuses...

By deleting organization alone, all objects defined in the CasCade Delete Rule will just being deleted in single line: ec.deleteObject(anOrganizaton); It saves you time to do delete iterations, and this is the beauty of WO without raw SQL.

Cheers

Cheong Hee


> Well the idea is to select a single primary key and then yes it to quickly delete a large number of records from a table.
>
> Using SQL query like this:
>
> DELETE FROM "cms"."ms_contestant" WHERE contest_id = (SELECT contest_id FROM "cms"."ms_contestant" WHERE contest_event = '2009 Contest');
>
> Rather then WebObjects code like this:
>
> NSArray contestants = contest.contestants();
>
> for(int i = 0; i < contestants.count(); i++){
> Contestant contesant = (Contestant)contestants.objectAtIndex(i);
>
>       ec.deleteObject(contestant);
>
> }

Well, that seems like the hard way.

How about:

contest.deleteAllContestantRelationships();

That will do basically what you've written above, but it's one line of code and will properly handle both sides of the relationship.

Or, if the contestant() relationship on Contest either Owns Destination or has a Cascade delete rule:

ec.deleteObject(contest);

I'm not sure what the SQL will look like for that though.

Are you running into performance problems, or simply anticipating them?

Dave


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/anjo%40krank.net

This email sent to [email protected]

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to