Re: qualifierWithQualifierFormat ???
Re: qualifierWithQualifierFormat ???
- Subject: Re: qualifierWithQualifierFormat ???
- From: David Avendasora <email@hidden>
- Date: Tue, 4 May 2010 13:54:08 -0400
On May 4, 2010, at 12:34 PM, Theodore Petrosky wrote:
> I copied the fetchJobs(EC, qual, sort) from the _Job.java and pasted into Job.java with the change "fetchSpec.setUsesDistinct(true);".
> Is this the recommended way to handle this?
>
>
> public static NSArray<Job> fetchDistinctJobs(EOEditingContext editingContext, EOQualifier qualifier, NSArray<EOSortOrdering> sortOrderings) {
> EOFetchSpecification fetchSpec = new EOFetchSpecification(_Job.ENTITY_NAME, qualifier, sortOrderings);
> fetchSpec.setUsesDistinct(true);
> fetchSpec.setIsDeep(true);
> NSArray<Job> eoObjects = (NSArray<Job>)editingContext.objectsWithFetchSpecification(fetchSpec);
> return eoObjects;
> }
That is the best way to handle this situation if you need the DB to handle the distinct, but you may get acceptable performance by simply using:
public static NSArray<Job> fetchDistinctJobs(EOEditingContext editingContext, EOQualifier qualifier, NSArray<EOSortOrdering> sortOrderings) {
return ERXArrayUtilities.arrayWithoutDuplicates(fetchJobs(editingContext, qualifier, sortOrderings));
}
It's less duplicated code, but it won't be as fast either. But if the array isn't that big it might not make much difference.
Dave _______________________________________________
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