Re: using named fetch specifications
Re: using named fetch specifications
- Subject: Re: using named fetch specifications
- From: Erik Kraft <email@hidden>
- Date: Sun, 8 Aug 2004 17:09:34 -0700
On 8 Aug 2004, at 16:27, William Norris wrote:
I've gotten my named fetch spec to work correctly, but it just feels
like I've got too much java code...
EOModelGroup modelGroup = EOModelGroup.defaultGroup();
EOFetchSpecification fs = modelGroup.fetchSpecificationNamed("Search",
"Course");
fs =
fs.fetchSpecificationWithQualifierBindings(courseDisplayGroup.queryBind
ings());
NSMutableArray searchResults = new
NSMutableArray(editingContext.objectsWithFetchSpecification(fs));
course = (Course)searchResults.objectAtIndex(0);
It looks about right. I've used named fetch specs and this is
basically the code I've written.
Changing yours just a bit I get (disclaimer: this hasn't even come
close to a compiler yet).
EOFetchSpecification fs =
EOModelGroup.defaultGroup().fetchSpecificationNamed("Search",
"Course");
fs =
fs.fetchSpecificationWithQualifierBindings(courseDisplayGroup.queryBindi
ngs());
NSArray searchResults =
editingContext.objectsWithFetchSpecification(fs);
// not sure why you need a mutable array, but if so use mutableClone()
instead of new NSMutableArray()
// NSMutableArray searchResults =
editingContext.objectsWithFetchSpecification(fs).mutableClone();
// You might want to check the number of results before you start
grabbing from the array.
course = (Course) searchResults.objectAtIndex(0);
like I said, it does work which I am happy about, but it just feels
like too much code for such a simple thing. I feel like i'm making
three lefts turns in order to turn right.
It would still be 3 lines or longer to do a search by programatically
generating the fetch spec, setting the qualifier(s), and fetching the
data.
What you've written isn't too much code. You are doing it the right
way.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.