Re: Qualifier with key path keywords
Re: Qualifier with key path keywords
- Subject: Re: Qualifier with key path keywords
- From: Sacha Mallais <email@hidden>
- Date: Mon, 25 Apr 2005 17:11:48 -0700
On Apr 25, 2005, at 4:42 pm, Greg wrote:
Hi,
I am wanting to find all the clients that have made more than 1
purchase. I have the following qualifier:
public NSArray customersWhoHaveBoughtMoreThanOnce() {
EOQualifier sales =
EOQualifier.qualifierWithQualifierFormat("sales.@count > 1", null);
EOSortOrdering lName =
EOSortOrdering.sortOrderingWithKey("lastName",
EOSortOrdering.CompareAscending);
EOSortOrdering fName =
EOSortOrdering.sortOrderingWithKey("firstName",
EOSortOrdering.CompareAscending);
Object args[] = {lName, fName};
EOFetchSpecification fetchSpec = new
EOFetchSpecification("Client", sales, new NSArray(args));
return
theSession().defaultEditingContext().objectsWithFetchSpecification(fetc
hSpec);
}
It throws an exception saying that it is a problem parsing the '@'. If
I remove the '@' symbol from the qualifier it too fails as there is no
count found. I read through the EOQualifier javadoc but it didn't show
any examples of building a qualifier with '@', but it too didn't say
whether or not it is illegal to do it.
Unfortunately, the "@" notation is only for NSArrays: it will not work
in a qualifier. You have two options:
- select/fault the required objects out of the database and execute the
aggregate function on the resulting array
- use raw SQL to perform the operation at the database
The former will work just fine (and will have nicer code than the
latter) if the result set is small. For larger result sets, you'll
want to use the latter solution. Note that the qualifier question
becomes moot if you already have the objects in memory (in which case,
use the "@" notation on the NSArray).
sacha
--
Sacha Michel Mallais - 800 lb. gorilla
Global Village Consulting Inc.: http://www.global-village.net/
ObAd: read "Practical WebObjects" <fnord>
http://www.global-village.net/products/practical_webobjects
_______________________________________________
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