• 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: Shared vs regular editing contexts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shared vs regular editing contexts


  • Subject: Re: Shared vs regular editing contexts
  • From: "Robert A. Decker" <email@hidden>
  • Date: Tue, 10 Feb 2004 10:31:37 -0800 (PST)

I've only been following this discussion closely enough to see that
there's mass confusion with shared ecs. :-) I experienced the same until I
came up with a simple system for accessing instances of shared entities.

For each entity that I declare shared, I only access instances of that
entity through static methods on its class.

For example, entity CallCenter has methods:

public static NSArray callCenters()

This uses the sharededitingcontext method
objectsByEntityNameAndFetchSpecificationName to pull out the array of
callcenters in the sharedec.

I then have another method:

public static NSArray callCenters(String fetchspecName, NSDictionary
bindings)

and in this method I use the fetch spec to do in-memory fetching out of
the callCenters array from the first method above, as well in-memory
sorting, etc using whatever rules are in the fetchspec.


I go through these hoops because I found that when I do a fetch of
CallCenters into a regular editing context they really are fetched into
memory into that context, which of course means that you can end up with
any number of callcenter copies in memory, defeating the whole purpose of
using a sharedec.

Of course, it works perfect if you're fetching a non-shared entity that
has a relationship into a sharedec - the relationship is traversed into
the sharedec, just like it should.


As far as editing shared entities, I've had no problem adding, deleting,
and updating using the rules that are covered in the documentation.
(although there is an annoying bug in WebObjects 4.5.1 where the sharedec
ignores a certain notification telling it to update, but that's fixed in
wo 5.x)


So, to keep things simple and easy to understand while you're coding,
if you need to access a shared entity on its own, just go through static
methods on the class. A little extra work upfront, but much less confusion
in the end.


thanks,
Robert A. Decker

http://www.robdecker.com/
_______________________________________________
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: 
 >Re: Shared vs regular editing contexts (From: Arturo PĂ©rez <email@hidden>)
 >Re: Shared vs regular editing contexts (From: Jonathan Rochkind <email@hidden>)

  • Prev by Date: Re: Shared vs regular editing contexts
  • Next by Date: Help Wanted / Freelance Developers
  • Previous by thread: Re: Shared vs regular editing contexts
  • Next by thread: Re: Shared vs regular editing contexts
  • Index(es):
    • Date
    • Thread