Re: Adding to relationships - what method to use?
Re: Adding to relationships - what method to use?
- Subject: Re: Adding to relationships - what method to use?
- From: LD <email@hidden>
- Date: Wed, 19 Oct 2005 16:30:44 +1000
Hi there,
On 19/10/2005, at 4:16 PM, Peter Vandoros wrote:
On 19/10/2005, at 4:13 PM, Greg Hulands wrote:
When adding to or removing from a to-Many relationship, what
method is the best practice?
[exclude | include]Object[From | Into]PropertyWithKey or
[add | remove]Object[To | From]BothSidesOfRelationshipWithKey
With the templates included with EOGenerator, it uses the first
one, but with other peoples templates they use the second one.
I have run into an issue with my code so I want to use the correct
way.
the safest and recommended way is to use
addObjectToBothSidesOfRelationshipWithKey and
removeObjectFromBothSidesOfRelationshipWithKey
Actually, if you're planning on using this within your EOCustomClass,
then you'll create an infinite loop doing that.
So you're first assumption was correct. i.e., include | exclude
public void addToProducts(Product object) {
includeObjectIntoPropertyWithKey(object, "products");
}
public void removeFromProducts(Product object) {
excludeObjectFromPropertyWithKey(object, "products");
}
From your WOComponents, Session, etc (i.e., anything other than your
relationship definitions in your EOCustomClass) you'll want to
utilise add|removeObject which is a shortcut for calling include|
exclude etc
with regards,
--
LD
_______________________________________________
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