Re: Binary primary keys
Re: Binary primary keys
- Subject: Re: Binary primary keys
- From: Cheong Hee Ng <email@hidden>
- Date: Wed, 2 Dec 2009 07:49:01 +0800
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@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden