Hi, I've got a hard time trying to get the fetch I want:), here's what I have: a parent entity "Product" which is abstract and 2 sub-entities "ProductA" and "ProductB" (one table for A and one for B in the database). A and B shares a common attribute "favorite" (define in Product) which is a NSTimestamp. If I try to fetch "Product" to get only product with a "favorite" NSTimestamp and sort it, I got 2 joined fetches... which is I first got the "ProductA" sorted correctly then the "ProductB" also sorted correctly. I'm not sure I explain this correctly, I mean the fetch isn't "Product sorted by favorite NSTimestamp" but instead "ProductA sorted by favorite NSTimestamp +ProductB sorted by favorite NSTimestamp".
Here's what I'm using to fetch: public NSArray topProductList() { NSMutableArray sortOrderings = new NSMutableArray(); EOSortOrdering newSO = new EOSortOrdering("favorite", EOSortOrdering.CompareCaseInsensitiveDescending); sortOrderings.addObject(newSO); EOQualifier qualifier = EOQualifier.qualifierWithQualifierFormat("(favorite <> null)", null); EOFetchSpecification fetchSpec = new EOFetchSpecification("Product", qualifier , sortOrderings); return new NSArray(editingContext.objectsWithFetchSpecification(fetchSpec)); }
I need to be able to get only the x last favorite, but actually it will only return ProductA (as long as there's more than x ProductA with a favorite NSTimestamp), so even if I have a more recent favorite ProductB, I can't get it...
Does anyone know how I can get a fetch really sorted on the parent entity?
Thanks
Xavier
PS: If there's a way not involving Project Wonder it would be really nice. I'm going to "upgrade" this project with Wonder after it is delivered, but actually I'm already late on the delivery and I can't afford the time to test everything to see if it works on Wonder, especially I have a custom WOHyperlink so I'm not sure it won't break using Wonder...But I may be wrong;) |