Setting setRefreshesRefetchedObjects using EOGenerator classes
Setting setRefreshesRefetchedObjects using EOGenerator classes
- Subject: Setting setRefreshesRefetchedObjects using EOGenerator classes
- From: Jeff Schmitz <email@hidden>
- Date: Sun, 26 Oct 2008 09:25:19 -0500
Hello,
I'd like to be able programatically set the
setRefreshesRefetchedObjects on specific fetch specifications to true
under certain, "run-time" situations to assure I have fresh data from
the database when a fetch is performed.
Using the EOGenerator generated "fetch" functions, the Fetch specs are
always local to the generated operations, so I'm thinking the only way
to do what I need would be to copy a "set" of fetch operations from
the generated EO code and change it accordingly in my edited EOCode as
shown below. Is there a simpler way to do this that I'm missing? Is
there a way to get EOGenerator to produce such functions?
Copied from _Entry.java, pasted into Entry.java and edited to add call
to setRefreshesRefetchedObjects:
public static NSArray<Entry> fetchRefreshedEntries(EOEditingContext
editingContext, EOQualifier qualifier, NSArray<EOSortOrdering>
sortOrderings) {
EOFetchSpecification fetchSpec = new
EOFetchSpecification(_Entry.ENTITY_NAME, qualifier, sortOrderings);
fetchSpec. setRefreshesRefetchedObjects(true);
fetchSpec.setIsDeep(true);
NSArray<Entry> eoObjects =
(NSArray<Entry>)editingContext.objectsWithFetchSpecification(fetchSpec);
return eoObjects;
}
public static Entry fetchRefreshedEntry(EOEditingContext
editingContext, String keyName, Object value) {
return _Entry.fetchRefreshedEntry(editingContext, new
EOKeyValueQualifier(keyName, EOQualifier.QualifierOperatorEqual,
value));
}
public static Entry fetchRefreshedEntry(EOEditingContext
editingContext, EOQualifier qualifier) {
NSArray<Entry> eoObjects =
_Entry.fetchRefreshedEntries(editingContext, qualifier, null);
Entry eoObject;
int count = eoObjects.count();
if (count == 0) {
eoObject = null;
}
else if (count == 1) {
eoObject = (Entry)eoObjects.objectAtIndex(0);
}
else {
throw new IllegalStateException("There was more than one Entry
that matched the qualifier '" + qualifier + "'.");
}
return eoObject;
}
thanks,
Jeff
_______________________________________________
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