• 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
Re: EOSharedEditingContext and objectsMatchingValues
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EOSharedEditingContext and objectsMatchingValues


  • Subject: Re: EOSharedEditingContext and objectsMatchingValues
  • From: Art Isbell <email@hidden>
  • Date: Thu, 9 Jan 2003 10:08:18 -1000

On Thursday, January 9, 2003, at 04:11  AM, Daniel Muller wrote:

I'd like to know if the below code is correct or not. I mean if it's correct to call EOUtilities.objectsMatchingValues with the default shared editing context:

EOSharedEditingContext sharedEC = EOSharedEditingContext.defaultSharedEditingContext();
myList = EOUtilities.objectsMatchingValues(sharedEC, "myEntityName", myMatchingDict );

For a decent discussion of object sharing, see http://developer.apple.com/techpubs/webobjects/WebObjects_4.5/System/ Documentation/Developer/WebObjects/DeltaDoc/EOF.html#CBGEDEHH.


EOSharedEditingContext is designed to be used in one's WOApplication subclass where the objects it fetches can be shared among all sessions. It is really best for all shared objects to be fetched when a WO instance starts up because each shared object fetch will block fetches in other editing contexts. So this makes me wonder whether the contents of myMatchingDict are set by each session. If so, then these objects probably should not be shared. If not, then I'd consider creating a fetch spec in my eomodel and setting some objects of myEntityName to be shared using this fetch spec. This will result in these objects being automatically fetched when the first access of an entity in your model is accessed. Because of this, you may need to "force" this automatic fetching by manually fetching objects from one of the entities not configured in the eomodel for sharing.

A shared editing context must be protected from multithreaded access should an app be run in multithreaded mode. Only EOSharedEditingContext's objectsWithFetchSpecification(), bindObjectsWithFetchSpecification(), faultForGlobalID(), and objectForGlobalID() are thread-safe. The documentation for EOUtilities.objectsMatchingValues() doesn't specify which EOSharedEditingContext method it uses, so there is some risk that it might not use a thread-safe method.

Shared objects automatically fetched can be accessed with the objectsByEntityName() and objectsByEntityNameAndFetchSpecificationName() methods. A problem I've experienced with these methods is that they don't seem to preserve the sort order in a sorted fetch so I've abandoned sorted fetches of shared objects instead sorting them when they're first accessed and caching the sorted results.

Shared objects can be very useful, but some care must be exercised in taking advantage of them.

Art
http://homepage.mac.com/aisbell/
_______________________________________________
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.

References: 
 >EOSharedEditingContext and objectsMatchingValues (From: Daniel Muller <email@hidden>)

  • Prev by Date: Re: WebObjects in Business
  • Next by Date: A bit of SQL help and logic correction, perhaps
  • Previous by thread: EOSharedEditingContext and objectsMatchingValues
  • Next by thread: WebObjects in Business
  • Index(es):
    • Date
    • Thread