• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
databaseContextShouldFetchObjects/databaseContextDidFetchObjects not working
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

databaseContextShouldFetchObjects/databaseContextDidFetchObjects not working


  • Subject: databaseContextShouldFetchObjects/databaseContextDidFetchObjects not working
  • From: Anjo Krank <email@hidden>
  • Date: Tue, 15 Apr 2008 10:41:04 +0200

All,

I also posted this as a bug report, but maybe I should ask here, too...

Following the docs on the DBC delegate methods, i'm trying to build an EO cache. The workings should be that databaseContextShouldFetchObjects() checks a cache for an identifier for the current fetch spec and return faults if a result is found. If none are found, null is returned and databaseContextDidFetchObjects() registers the fetched gids.

This is working for some fetches but sometimes I get an EOObjectNotAvailable exception which gets triggered at some later state. As I'm pretty certain I'm doing nothing wrong, can you verify that this code should work and if not, update the docs that one needs to do some other voodoo too (registering snapshots, etc) or that this method does NOT work across ECs?

This one is called from databaseContextShouldFetchObjects:

public NSArray<? extends EOEnterpriseObject> objectsForFetchSpecification(EODatabaseContext dbc, EOEditingContext ec, EOFetchSpecification fs) {
String identifier = ERXFetchSpecification.identifierForFetchSpec(fs);
synchronized (cache) {
NSArray<EOEnterpriseObject> eos = cache.objectForKey(identifier);
NSArray result = null;

if(eos != null) {
result = ERXEOControlUtilities.localInstancesOfObjects(ec, eos);
}
boolean hit = result != null;
if(hit) {
log.info("Cache : " + (hit ? "HIT" : "MISS") + " on " + fs.entityName());
}
return result;
}
}




This one is called from databaseContextDidFetchObjects:
public void setObjectsForFetchSpecification(EODatabaseContext dbc, EOEditingContext ec, NSArray<?> eos, EOFetchSpecification fs) {
String identifier = ERXFetchSpecification.identifierForFetchSpec(fs);
synchronized (cache) {


boolean shouldCache = shouldCache(eos, fs);
if((ec.parentObjectStore() instanceof EOObjectStoreCoordinator) && shouldCache) {
cache.setObjectForKeyWithVersion((NSArray<EOEnterpriseObject>) eos, identifier, null, 60000L);
}
if(shouldCache) {
log.info("Cache : SET on " + fs.entityName());
} else {
log.debug("Cache : DROP on " + fs.entityName());
}
}
}




I had various other methods, one that stored only the GIDs and one that stored the EOs, but localinstance'd them. None worked reliably. If anyone can confirm that this should work, I'll try and create a test case where it does not.

Cheers, Anjo
_______________________________________________
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


  • Prev by Date: Re: new to ajax
  • Next by Date: Re: new to ajax
  • Previous by thread: Re: ERD2WEditPercentage (setting the values)
  • Next by thread: Strange behaviour of AjaxSortableList
  • Index(es):
    • Date
    • Thread