Re: EOSortOrdering based on a @count relationship
Re: EOSortOrdering based on a @count relationship
- Subject: Re: EOSortOrdering based on a @count relationship
- From: Ian Joyner <email@hidden>
- Date: Tue, 9 Jan 2007 11:08:03 +1100
Please don't post your messages to both WO-Dev and Omni list. All
people end up with is duplicate messages, since most people receive
both groups.
On 09/01/2007, at 10:51 AM, Dev WO wrote:
Hi,
I've been trying to isolate the issue with this, but I just can't
even get an error...
So I need to sort based on a calculated attribute: relationship
().count()
but I just can't make it work...
I've got entity "a" which has a toMany relationship "relationship()".
I need to sort "a" entities based on relationship().count().
So here's my SortOrder:
--------
public Number numberOfComments() {
return (Number)writeCommentaries().count();
}
public NSArray sortOrderingByCommentaries() {
NSMutableArray sortOrdering = new NSMutableArray();
EOSortOrdering newSO = EOSortOrdering.sortOrderingWithKey
("numberOfComments", EOSortOrdering.CompareDescending);
sortOrdering.addObject(newSO);
return (NSArray)sortOrdering;
}
--------
and the actual sorted array:
--------
public NSArray listOfNewsSortedByCommentaries() {
return (NSArray)EOSortOrdering.sortedArrayUsingKeyOrderArray
(listOfNews(), new NSArray(sortOrderingByCommentaries()));
}
--------
but it won't work, I don't even get a crash, just a "no instance
available"...
I tried with another Number attribute to see if it coud be the
cause, but it works. I also sort using another attribute and
display the relationship().count() for each "a" and it works. It
seems I just can't sort using the relationship().count().
But I though I could use custom attribute as long as the array is
already in an editing context.
I must miss something, but I can't find it...
Thanks for your help
Xavier
_______________________________________________
WebObjects-dev mailing list
email@hidden
http://www.omnigroup.com/mailman/listinfo/webobjects-dev
_______________________________________________
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