Re: EOModelGroup defaultGroup question
Re: EOModelGroup defaultGroup question
- Subject: Re: EOModelGroup defaultGroup question
- From: Chuck Hill <email@hidden>
- Date: Mon, 19 Nov 2007 16:00:46 -0800
On Nov 19, 2007, at 3:45 PM, Scott Lopatin wrote:
Hi!
I have a method like the one below, where I want to send in a model
with a different connection dictionary and execute a fetch using
the alternate model database. I'm running the below, setting the
new default group, then setting it back, however the results always
appear to come from the regular default model group, not the new
model group I'm setting below. Does anyone see something I'm missing?
Thanks,
Scott
public static NSArray executeSQLForModelWithResults
(EOEditingContext ec, String sql, EOModel model) {
// Save defaultGroup
EOModelGroup defaultGroup = EOModelGroup.defaultGroup();
defaultGroup.models().containsObject(model) == false, right? But it
contains a different instance of EOModel that has the same entities?
// Create new group
EOModelGroup newGroup = new EOModelGroup();
newGroup.addModel(model);
EOModelGroup.setDefaultGroup(newGroup);
Probably not a good idea to mess with this... Things run deeper here.
// perform fetch
NSArray results = EOUtilities.rawRowsForSQL(ec, "modelname", sql,
null);
ec's are model group / EOF stack specific. You can not pass in an EC
like that. You need a whole new EOF stack with a new database,
database context, and object store co-ordinator.
Chuck
// reset group to default
EOModelGroup.setDefaultGroup(defaultGroup);
return results;
}
--
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
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