Hi, Benoit and Tony,

I'm concerned about the following response because it's dangerous. Here is the advice given at

http://en.wikibooks.org/wiki/Programming:WebObjects/EOF/ Using_EOF/Context_and_Database_Locking

============================================
David LeBer:

In general you are better to lock EC's in the session (if you've got one) rather than the component.

As that is the usual approach, there are a couple of solutions to implement that for you:

MultiECLockManager
Project Wonder's ERXEC
Jonathan Rochkind:

Note: One very handy (if I do say so myself) reusable solution for locking ECs you create (not neccesary for session default EC) can be found at: http://WOCode.com/cgi-bin/WebObjects/WOCode.woa/wa/ ShareCodeItem?itemId=301

Anjo Krank:

One thing to watch out for is that EC locking on the page's awake() and sleep() doesn't really work, because awake may be called more often than sleep. This means that normally you can't use DirectToWeb because it does just that. However, ProjectWonder has an editing context factory, an automatically locking and unlocking EC subclass and a lock manager that will relaese all locks when the application sleeps.

This works nicely with long response pages, provided that you don't use the session's editing context in the long running task.
============================================

Regards,
Jerry


On Jun 12, 2007, at 4:07 AM, Anthony Paras wrote:

In my apps, I've done the following in my components when I've needed a peer
editing context, and I've never had any problems:

    public EditFooInfo(WOContext context) {
        super(context);
        ec = new EOEditingContext();
    }
    public void awake() {
        super.awake();
        ec.lock();
    }
    public void sleep() {
        super.sleep();
        ec.unlock();
    }

You might want to log the locks and unlocks to see that they match up.

Also, you have so many sessions, yet you say you don't need sessions. You could structure the app so it does not create sessions, or maybe just use
the session, and then do a...

    session().setTimeOut(1);

To make them go away quickly.

- Tony


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/jerrywwalker% 40gmail.com

This email sent to [EMAIL PROTECTED]


--
__ Jerry W. Walker,
WebObjects Developer/Instructor for High Performance Industrial Strength Internet Enabled Systems

    [EMAIL PROTECTED]
    203 278-4085        office



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to