EOSortOrdering based on a @count relationship

Dev WO <[email protected]>
Newsgroups gmane.comp.web.webobjects.devel
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.