Re: mutually exclusive 1-to-0 or 1 relationship modeling
Re: mutually exclusive 1-to-0 or 1 relationship modeling
- Subject: Re: mutually exclusive 1-to-0 or 1 relationship modeling
- From: Ramsey Gurley <email@hidden>
- Date: Fri, 14 Jan 2011 11:55:12 -0500
On Jan 14, 2011, at 11:46 AM, Ramsey Gurley wrote:
On Jan 14, 2011, at 11:16 AM, Michael Gargano wrote:
I have three entities A, B, and C...
A has a 1-to-0 or 1 with B
and
A has a 1-to-0 or 1 with C
An entry in A either has an entry in B or an entry in C. The two
are mutually exclusive. When I try to set this up in the modeler
it gives me some problems. Once I set a relationship as a one-to-
one, the modeler won't let me select optional if optional is
already unselected and the modeler generates a warning about having
optional set if I edit the plist directly. I'm not sure if I'm
doing this correctly, but it looks to me like the modeler isn't
allowing 1-to-0 or 1 relationships.
So, if I just live with the warnings...
If I set the relationship between A and B and set the relationship
to C to null (again because B and C are mutually exclusive), when I
save changes it throws an exception complaining that all the
properties in B are null. Anyone else doing something like this?
Thanks.
-Mike
Hi Mike,
You can just create two regular toOne relationships and override
public String inverseForRelationshipKey(String key)
In your A, B, and C java files to connect them.
You can do model based validation for the mutual exclusion with
Wonder's ERXEntityClassDescription. Just check the java docs on that
class for an explanation of the userInfo keys you can use.
Alternately, you can just use validateKey methods on your A,B,and C
java classes to achieve the same effect.
Ramsey
Oops, I just read Kieran's reply. He's right, I meant validateForSave
not validateKey.
Ramsey
_______________________________________________
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