• 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 EC problems for a newbie
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shared EC problems for a newbie


  • Subject: Re: Shared EC problems for a newbie
  • From: Art Isbell <email@hidden>
  • Date: Thu, 23 Feb 2006 13:59:39 -1000

On Feb 23, 2006, at 12:37 PM, Timmy wrote:

I've got a set of EOs that are fetched in Application by a EOSharedEditingContext. These are objects that are used to populate lists in my application. I have a component where an admin type can (hopefully) alter these objects when/if truly necessary - but it would be rare. So, they are truly "read mostly"/"write rarely" objects.

I have a method that attempts to edit one of these EOs and to accomplish that attempts to get a copy of the EO in a local editing context.

In case you didn't see Ben Trumbull's message about updating shared objects:


On Nov 16, 2005, at 1:45 PM, Ben Trumbull wrote:

People successfully use shared ECs in concurrent apps, although updating shared objects is very difficult to do correctly. I've seen it done by taking a large granularity lock in the request handler. However, the following approach *should* work, and be less drastic than that sledgehammer:

regularEC = new EOEditingContext();
regularEC.lock();
try {
    regularEC.setSharedEditingContext(null);

// fetch or fault the currently shared objects to update into regularEC
// update the ex-shared objects in regularEC


    sharedEC.lock();
    objectStoreCoordinator.lock();

    try {
        regularEC.saveChanges();
    } finally {
        objectStoreCoordinator.unlock();
        sharedEC.unlock();
    }
} finally {
    regularEC.unlock();
    regularEC = null;
}

The ordering of the lock/unlocking is important and must not be changed.

In my method I have the following line:


EntityName _myLocalEO = (EntityName) EOUtilities.localInstanceOfObject(myPageContext(),entityItem());



myPageContext() returns a new local EOEditingContext that is a child of the session's defaultEditingContext (I think). It is instantiated like this:



setMyPageContext(new EOEditingContext((Session)session ().defaultEditingContext()));

If myPageContext() is the editing context you are using to update a shared object, be sure to send it a setSharedEditingContext(null) message.


The line calling EOUtilities.localInstanceOfObject() above throws a null pointer exception and I can't figure out exactly why this is happening. Below is the crash dump starting with my method (removeDosTypeFromUse()). None of the arguments I am passing into localInstanceOfObject are null.

[2006-02-23 14:11:10 PST] <WorkerThread0> java.lang.NullPointerException
at com.webobjects.eocontrol.EOEditingContext.faultForGlobalID (EOEditingContext.java:3678)
at com.webobjects.eoaccess.EOUtilities.localInstanceOfObject (EOUtilities.java:942)
at DosCodesPage.removeDosTypeFromUse(DosCodesPage.java:173)


Can anyone point me in the right direction?

Ensure that entityItem() is in an editing context.

Aloha,
Art

_______________________________________________
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: Shared EC problems for a newbie
      • From: "Randy Wigginton" <email@hidden>
References: 
 >Out of order SQL statements? (From: "John Huss" <email@hidden>)
 >Re: Out of order SQL statements? (From: Jacky Gagnon <email@hidden>)
 >Shared EC problems for a newbie (From: Timmy <email@hidden>)

  • Prev by Date: Shared EC problems for a newbie
  • Next by Date: Re: EO Model (not the standalone EOModeler) in Xcode
  • Previous by thread: Shared EC problems for a newbie
  • Next by thread: RE: Shared EC problems for a newbie
  • Index(es):
    • Date
    • Thread