• 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: in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!?


  • Subject: Re: in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!?
  • From: Ken Anderson <email@hidden>
  • Date: Fri, 27 Feb 2015 08:31:31 -0500

OC,

FYI - best practices are:

create EC
lock EC
try {
// operations
} catch (Exception e) {
// exception handling
} finally {
unlock EC
}

In your code, if an exception is thrown creating the EC, your finally block will try to unlock it and generate an NPE.

Ken


On Feb 27, 2015, at 2:48 AM, OC <email@hidden> wrote:

Chuck,

On 27. 2. 2015, at 5:44, Chuck Hill <email@hidden> wrote:

I am not. Again I might be missing something, but I understand ERXEC does autolock -- even in a background thread -- as needed, albeit possibly not in the most efficient manner (e.g., http://lists.apple.com/archives/Webobjects-dev/2007/May/msg00578.html).

Assuming you have the properties set properly.

Based on what I have found on the Web, I have this in my Properties:

===
er.extensions.ERXEC.safeLocking=true
er.extensions.ERXEC.useSharedEditingContext=false
er.extensions.ERXApplication.useEditingContextUnlocker=true
er.extensions.ERXEC.defaultAutomaticLockUnlock=true
er.extensions.ERXEC.defaultCoalesceAutoLocks=true
===


(Besides frankly, I don't really see the need to lock an EC at all, given the EC is created, used and released in one separate thread and never shared anyhow with other threads; but then, superfluous locking does not harm anything but efficiency, and efficiency is not paramount with background threads.)

You not seeing the need, does not mean the need is not there.  :-)  EOF sends out a lot of notifications, an unlocked EC will process those notifications immediately and that can mutate the EO state (attributes, relationships).  You won’t have a consistent view of the world in an unlocked EC.  The object state can change on you at any time, without warning.  Have fun with that!  :-)

Anyway, just to be triple sure, I have changed my task code to

===
class ImportCSVTask extends ERXLongResponseTask.DefaultImplementation {
    ...
    def editingContext
    ...
    def performAction {
        ...
        try {
            editingContext=ERXEC.newEditingContext(objectStore=new EOObjectStoreCoordinator())
            editingContext.lock()
            ... all the processing here, actually imports CSV, stores objects to editingContext and saves it ...
        } finally {
            editingContext.unlock()
        }
    }
}
===

I hope there's no problem with that?

Thanks again,
OC


 _______________________________________________
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

References: 
 >in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!? (From: OC <email@hidden>)
 >Re: in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!? (From: Ken Anderson <email@hidden>)
 >Re: in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!? (From: OC <email@hidden>)
 >Re: in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!? (From: Chuck Hill <email@hidden>)
 >Re: in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!? (From: OC <email@hidden>)

  • Prev by Date: Re: D2W Rules
  • Next by Date: No template found for component Main
  • Previous by thread: Re: in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!?
  • Next by thread: Re: in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!?
  • Index(es):
    • Date
    • Thread