Re: EOOrQualifier generated from an array
Re: EOOrQualifier generated from an array
- Subject: Re: EOOrQualifier generated from an array
- From: Ken Anderson <email@hidden>
- Date: Mon, 25 Dec 2006 10:24:40 -0500
Clark,
You should look at all the qualifier classes. To do what you're
asking, you would do something like this (NOT guaranteed to compile):
NSMutableArray orQualifiers = new NSMutableArray();
Enumeration locationEnum = locations.objectEnumerator();
while (locationEnum.hasMoreElements()) {
Location location = (Location) locationEnum.nextElement();
EOKeyValueQualifier qual = new EOKeyValueQualifier
("LOCATIONKEYPATH", EOQualifier.QualifierOperatorEqual, location);
}
EOOrQualifier orQualifier = new EOOrQualifier(orQualifiers);
EOKeyValueQualifier serialQual = new EOKeyValueQualifier("serialNo",
EOQualifier.QualifierOperatorEqual, "SERIALNO");
EOAndQualifier finalQualifier = new EOAndQualifier(new NSArray(new
Object[] {serialQual, orQualifier}));
Again, this is from my memory, and I haven't tried to compile it, but
hopefully you get the idea. Just create the fetch spec with
finalQualifier.
Ken
On Dec 25, 2006, at 2:25 AM, Clark Mueller wrote:
Hello all,
I have a question about fetch specs, and use of arrays as an
argument (or not). To me, it seems like intuitive behavior that
passing an array as an argument to a fetch spec should generate an
"or" qualifier string based on the elements of that array.
Suppose, for example, that I have an entity Inventory and Location.
I have a fetch specification for Inventory that looks like
"serialNo = $serialNo and location = $location". I would like to be
able to pass an array of Locations to this fetch specification,
such that a query is created looking like:
select ... from inventory where serialNo = $serialNo and
(location=location1 or location=location2 or location=location3)
I'm pretty sure I've seen mention of this behavior before, but I
don't quite see how to implement it. Is that something I can use
joins for, or is there another way to do it other than manually
building the qualifier?
Thanks,
Clark
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40anderhome.com
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