• 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: Many-to-many across ECs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Many-to-many across ECs


  • Subject: Re: Many-to-many across ECs
  • From: Travis Britt <email@hidden>
  • Date: Sun, 6 Feb 2005 11:06:45 -0500

On Feb 6, 2005, at 9:23 AM, Drew Thoeni wrote:
I have a many-to-many (students-to-classes) and I have the class list placed into an EC at the application level (since it's established, read-only, and shared by all users).
[...]
The code I'm using is below (where aClass is in the application EC)
aClass.addObjectToBothSidesOfRelationshipWithKey(session.currentStudent , "students");

Both the objects need to be in the same regular editing context.

I'm guessing by application EC you mean an EOSharedEditingContext? If you're adding an object to a aClass's relationship then it isn't read only. Top-of-the-head code for putting aClass in a regular editing context:

regEC = new EOEditingContext();
regEC.lock();
try {
  regEC.setSharedEditingContext(null);
  EOUtilities.localInstanceOfObject(regEC, aClass);
  // Do stuff
} finally {
  regEC.unlock();
}

Note that it is generally a bad idea to have a relationship from a shared object to non-shared objects. When faults for that relationship are fired the non-shared objects end up in the shared editing context. You can remove those relationships from the model. Or, ahem, assume that all objects are shared (or check their EC at runtime). Regardless, some planning is required. The easiest way to go is to use the shared context for objects that are read-mostly for the duration of the app instance and don't have relationships to objects you don't expect to be shared. Except for simple cases (objects that represent city names or zip codes -- something generally unchanging and isolated) I tend to think of the shared context as an optimization and don't use it unless the app's performance requires it.

tb

_______________________________________________
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


  • Follow-Ups:
    • Re: Many-to-many across ECs
      • From: Drew Thoeni <email@hidden>
References: 
 >Many-to-many across ECs (From: Drew Thoeni <email@hidden>)

  • Prev by Date: Re: recuperate session from a directAction
  • Next by Date: Number Formatters not working ERXExtensions...
  • Previous by thread: Many-to-many across ECs
  • Next by thread: Re: Many-to-many across ECs
  • Index(es):
    • Date
    • Thread