EOSortOrdering based on a @count relationship
EOSortOrdering based on a @count relationship
- Subject: EOSortOrdering based on a @count relationship
- From: Dev WO <email@hidden>
- Date: Tue, 9 Jan 2007 00:51:18 +0100
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
_______________________________________________
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