If I do as you wrote, I will have (I think) the same issue because I will have
to use the addToCompaignRelationship method on contact that will add it to the
'saveChange' list, isn't it ?
And if I brake the reverse link between contact and xxcampaigncontact that will
avoid long save, WO wil complains because I had issues where it dislikes many
to many not flattened in both sides.
With your idea, I had a new one and created a new table for "lightweight"
between contact and xxcampaigncontact to reduce number of rows.
My first tests show that where I needed 3 minutes, I now only need 20 secondes
to save and I still have my relationships in my Model so it's easier, I just
need to use contact.lightweight().compaigns() instead of contact.compaigns().
Thank's,
Jérémy
Le 20 sept. 2011 à 10:46, Kieran Kelleher a écrit :
> You don't say how many contacts you are adding to the campaign <<-->>
> contacts relationship, but based on the description of you problem I am
> assuming it is huge, way beyond 10,000, maybe beyond 100,000 or 1,000,000.
>
> In any case, it seems like you are hitting the EOF huge to-many relationship
> (EOF comparing the previous huge NSArray of to-many items to the new huge
> changed to-many item NSArray) problem…. and yes, this kills performance.
> For simple to-many A<-->> B solving it is a little easier. For
> many-to-many, it is solved in a similar way.
>
>
> So you have something like the following, where xxcampaigncontact is the
> assumed name of the "join" entity:
>
> campaign <-->> xxcampaigncontact <<--> contact
>
> You need to change your EOModel as follows by deleting both the "contacts"
> item and the grayed out 'xxcampaigncontact' items in the relationship section
> of the 'campaign' entity. Thus you are removing the offending huge to-many
> between campaign and xxcampaigncontact.
>
> campaign <-- xxcampaigncontact <<--> contact
>
> Then you will need to write business logic methods in your campaign.java
> class to fetch contacts and do other contact manipulation using "reverse
> relationship" (contact to campaigns) manipulation logic.
>
> For example, you may want to add a contactsQualifier() method to campaign
> that will look like this:
>
> protected EOQualifier _contactsQualifier;
>
> public EOQualifier contactsQualifier() {
> if (_contactsQualifier == null) {
> _contactsQualifier =
> Contact.CAMPAIGNS_KEY.containsObject(this);
> }
> return _contactsQualifier;
> }
>
> And then to fetch a campaign's contacts, use a fetch spec having the
> qualifier above.
>
> To add contacts to a campaign's contacts, you convenience method in your
> campaign.java to add the campaign to a contact's campaigns relationship
> instead.
>
> contact.addToCampaignsRelationship( campaign );
>
> In the case of a regular huge to-many relationship, a convenience class like
> ERXUnmodeledToManyRelationship can be used. Referring to this may help you
> get your head around your current problem.
>
> HTH, Kieran
>
>
>
> On Sep 20, 2011, at 2:56 AM, Jérémy DE ROYER [INGENCYS] wrote:
>
>> Hi All,
>>
>> I have an editing context question.
>>
>> I've got 2 tables : contact and compaign
>>
>> I want to add contacts to a compaign so I've created a many to many
>> relationship between the table contact and the table compaign. That work
>> fine.
>>
>> Problem is that when I add (lots of) contacts to a compaign because
>> webobjects, when updating database with saveChanges(), update all contacts
>> in database (even if fields of contacts haven't been changed).
>>
>> For table with 5 rows, I takes 20 secondes for 1000 added contacts, that's
>> ok.
>>
>> But for table with more than 50 rows, I takes more than 2 minutes.
>>
>> What's the best solution to avoid that wast of time (that make problem when
>> submitting form that takes to many time... for nothing)
>>
>> I though about :
>> - creating "linking" table with no data row to avoid long save, but I have
>> to change all my model...
>> - remove contact from updatedObjects set, but that's dirty because
>> willUpdate methods won't be called
>>
>> Any idea to avoir SQL update on objects that didn't changes except to Many
>> Relationship ?
>>
>> Jérémy _______________________________________________
>> 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/kelleherk%40gmail.com
>>
>> 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]