Deleted Object Becoming Updated Object During processRecentChanges
Chuck Hill <[email protected]>
| Newsgroups | gmane.comp.web.webobjects.eof |
|---|---|
| Organization | Global Village Consulting, Inc. |
| Message-ID | <[email protected]> |
Hi,
I'm coming close to losing my mind over this one...
I've got two EOs, Table and Column. Table has many Columns, each Column has one
Table. Table cascade deletes Columns. A Column nullifies it's Table's
reference upon deletion. I'm working with a third EO that is a sub-class of a
sub-class of Table.
Here is the code:
EOEditingContext ec = new EOEditingContext();
ec.lock();
// selectedDatabaseTable() is a sub-class of a sub-class of Table
Table tableToDelete = (Table) EOUtilities.localInstanceOfObject(ec,
selectedDatabaseTable());
ec.deleteObject(tableToDelete);
// This next line was added for debugging
ec.processRecentChanges();
ec.saveChanges();
ec.unlock();
The symptom I am seeing is that validateForSave is getting called on
tableToDelete after the delete rules have been applied. However, this only
happens in one specific situation: deleting a new table that has just been
created an saved in session().defaultEditingContext(). If the table is created
and then the user logs out and in, then deletion proceeds normally. The
deletion proceeds normally if the application is stopped and restarted. The
deletion proceeds normally if another user logs in and deletes it while the
creating session is still active.
I notice that if I print out ec.updatedObjects() and ec.deletedObjects() before
and after ec.processRecentChanges(), that tableToDelete has been removed from
deletedObjects() and added to updatedObjects() when processRecentChanges()
returns. This would explain why validateForSave() is being called on it.
After much debugging and hair pulling I've determined (or think that I have
determined) that this is caused by processRecentChanges() firing a fault for a
Column object that triggers a trip to the database. This seems to be happening
at the wrong time when the table was recently created. I can avoid the error I
am getting by iterating over tableToDelete.columns() and manually firing the
faults by printing out an attribute.
Possibly somewhat related is my use of
EOEditingContext.setDefaultFetchTimestampLag(2000);
If I set this up from two seconds to twenty seconds, and delete the table within
20 seconds of creating it, then I see no error. However, if I wait longer than
20 seconds the result is the same as having this at two seconds.
Does anyone have any ideas on why this might be happening only after the EO is
created?
Chuck
--
Chuck Hill - Village Idiot Savant [email protected]
Global Village Consulting Inc. http://www.global-village.net