Hi Peter,

On Jan 8, 2008, at 9:23 PM, Peter Vandoros wrote:

Hi List,

I came across an interesting behaviour today with awakeFromInsertion () that i did not expect and I hope someone could shed some light.

What happens is that awakeFromInsertion() is not only called when the EO is "created" but also when reverting the editing context after having deleted an EO (which hasn't yet been saved). That is, if you delete an EO and revert() instead of saveChanges(), that EO's awakeFromInsertion() method is called again.

The documentation states:
"Overridden by subclasses to perform additional initialization on the receiver upon its being inserted into ec. This is commonly used to assign default values or record the time of insertion. ...."

I originally took this to mean that it is only called when the EO is _created_. Technically speaking, the documentation states that it is called when the EO is _inserted_ into the editing context which does not necessarily mean when the EO is _created_.

Does this mean that I need to go through all my EO's that use this method for some initialisation and take this scenario into account or is this a bug with WO?
I am using WO 5.2.4.

Is this what you are talking about?

com.webobjects.eocontrol.EOEditingContext ec = newEditingContext();
ec.lock();
Order o = new Order();
ec.insertObject(o);
ec.deleteObject(o);
ec.revert();
ec.unlock();

I log a stack trace from Order.awakeFromInsertion. I do not get a call to awakeFromInsertion when the ec is reverted in WO 5.3.3.

Log out a stack trace from awakeFromInsertion and see what it says for the second call:

    public void awakeFromInsertion(EOEditingContext ec)
    {
        NSLog.out.appendln(new RuntimeException("backtrace"));
        super.awakeFromInsertion(ec);
        . . .

I'd be interested to see it.


Chuck

--

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects





_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
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