Re: SELECT objects with condition on all their relationships
Re: SELECT objects with condition on all their relationships
- Subject: Re: SELECT objects with condition on all their relationships
- From: Ken Anderson <email@hidden>
- Date: Sat, 07 May 2005 17:46:04 -0400
OK, so to make sure I understand, and to recap for everyone else, you're looking for a way to say that all objects in a to-many relationship meet a condition?
As far as I know, this is not possible in SQL. Whenever you say x.y = z in a where clause, if any object related to x in this way matches z, it will consider x a valid part of the set.
If you had the results in memory, there's no reason you couldn't write an EOQualifier that would do what you require. Is that a possibility?
Ken
On May 7, 2005, at 10:59 AM, DevReseune wrote:
No, it's not my problem, but thanks for your response.
I want to find all Enterprises for which all Employees check a condition. If you create a qualifier condition like:
"employees.data = nil"
you will find all Enterprises for which at least one Employee checks this condition. I don't know how to do for "all" objects of a relationship.
I hope that I was more comprehensible ;-)
Frédéric
Le 6 mai 05 à 20:56, Ken Anderson a écrit :
While your title suggests firing a relationship, you mention EOQualifiers in your text, so I'm not sure if you're attempting to get a subset of a relationship, or just do an open query.
If you want to get a subset of a relationship and the relationship results are not large (and will not grow to be large), you could always write a method on the object that would just iterate over the relationship and return the right group. If the result set would normally be too large, I would suggest either changing the way the schema works, or creating a subentity of the target entity in a way that one sub-entity of the target entity would be the desired set.
As an example, if you have a relationship to an object that stores a complete history (like maybe customer->>orders), and you just want the open orders, you might consider subclassing order to have CompleteOrder and OpenOrder, qualifying the subclasses on open=TRUE or something like that. In this way, you could have customer->>completeOrders and customer->>openOrders.
If you want to generate a query, you can just create an EOQualifier with the right condition, like:
EOQualifier.qualifierWithQualifierFormat("condition=%@", new NSArray(desiredCondition));
Does this answer your question?
Ken Anderson
President
Going Flying, Inc.
On May 6, 2005, at 12:36 PM, DevReseune wrote:
Hi,
I want to select all Enterprise objects that all their Employees check a condition. I don't know how to create an EOQualifier to do that. I know how to select enterprises that at least one employee checks the condition, but not all.
Thanks for your response.
Frédéric _______________________________________________
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
_______________________________________________
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