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 protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to