Re: Snapshot problems
Re: Snapshot problems
- Subject: Re: Snapshot problems
- From: Peter Vandoros <email@hidden>
- Date: Fri, 20 Apr 2007 14:45:29 +1000
Hi Steven,
See comments below.
<snip>
This works great also. The KitQuantities are visibly represented on
the page, they are definitely in the database, and I can even print
out the snapshot for the items for both editing contexts as they are
created, and everything is perfect. If I were to quit the
application, restart, and come back to this page and edit this item, I
could delete the KitQuantities without a care in the world. But if I
immediately start deleting the NEWLY CREATED KitQuantity items, I run
into problems. Usually (but not always) the first one deletes ok, but
at some point in deleting the remaining ones, I get the following
exception:
java.lang.IllegalStateException: recordDeleteForObject:
com.webobjects.eoaccess.EODatabaseContext
com.webobjects.eoaccess.EODatabaseContext@c5627c failed to find a
snapshot for EO with Global ID:_EOIntegralKeyGlobalID[KitQuantity
(java.lang.Integer)1216] that has been deleted from
er.extensions.ERXECer.extensions.ERXEC@b88745. Cannot delete an object
that has not been fetched from the database
[2007-04-19 23:06:49 EDT] <WorkerThread9>
java.lang.IllegalStateException: recordDeleteForObject:
com.webobjects.eoaccess.EODatabaseContext
com.webobjects.eoaccess.EODatabaseContext@c5627c failed to find a
snapshot for EO with Global ID:_EOIntegralKeyGlobalID[KitQuantity
(java.lang.Integer)1216] that has been deleted from
er.extensions.ERXECer.extensions.ERXEC@b88745. Cannot delete an object
that has not been fetched from the database
at
com.webobjects.eoaccess.EODatabaseContext.recordDeleteForObject(EODatabaseContext.java:4926)
at
com.webobjects.eoaccess.EODatabaseContext.recordChangesInEditingContext(EODatabaseContext.java:6059)
at
com.webobjects.eocontrol.EOObjectStoreCoordinator.saveChangesInEditingContext(EOObjectStoreCoordinator.java:412)
at
com.webobjects.eocontrol.EOEditingContext.saveChanges(EOEditingContext.java:3226)
at er.extensions.ERXEC._saveChanges(ERXEC.java:947)
at er.extensions.ERXEC.saveChanges(ERXEC.java:870)
at EditKitHelper.removeItem(EditKitHelper.java:77)
I have seen similar symptoms to what you are describing but not the
exact same error. I found that error lied in the model with an
inconsistency between pk values in newly inserted objects and ones
retrieved from the database.
I can't remember exactly what the cause of the issue was, but it had to
do with my eoprototypes not being defined correctly and the the pk value
returned by the jdbc plugin when EOF asks for a new primary key for an
object. I fixed this issue with MySQL in my own custom MySQL jdbc plugin
and also submitted a patch for the PostgreSQL jdbc plugin in Project
WOnder, which was committed.
The only thing i can suggest to try and help find out if it is this
issue is to print as many snapshots and every layer of EOF that you can.
I.e. print the snapshot of the relevant EO's before and after edit/save
changes/delete and try to go all the way to EODatabase and print it's
snapshot and compare the pk's.
Below is some code i have used to test for this.
public void debugEOSnapshot() {
EOEditingContext ec; // assume ec exists. i.e. your ec
String primaryKeyAttributeName =
"<your_primary_key_attribute_name>";
EOEnterpriseObject eo; // assume exists
NSDictionary snapShot = ec.committedSnapshotForObject( eo );
Object pkField = snapShot.objectForKey( primaryKeyAttributeName );
Object oldPkField; // get this at time of eo "edit set up"
NSDictionary updateSnapShot = ec.currentEventSnapshotForObject(
eo );
Object updatePkField = updateSnapShot.objectForKey(
primaryKeyAttributeName );
if ( pkField != null ) {
System.out.println("new pkField: " + pkField + " (" +
pkField.getClass().getName() + ")");
}
else {
System.out.println("new pkField is null");
}
if ( updatePkField != null ) {
System.out.println("update pkField: " + updatePkField + " ("
+ updatePkField.getClass().getName() + ")");
}
else {
System.out.println("update pkField is null");
}
if ( oldPkField != null ) {
System.out.println("old pkField: " + oldPkField + " (" +
oldPkField.getClass().getName() + ")");
}
else {
System.out.println("old pkField is null");
}
if ( pkField != null && updatePkField != null ) {
System.out.println("new pkField == update pkField: " +
(pkField == updatePkField));
System.out.println("new pkField.equals(update pkField): " +
pkField.equals(updatePkField));
}
if ( pkField != null && oldPkField != null ) {
System.out.println("new pkField == old pkField: " + (pkField
== oldPkField));
System.out.println("new pkField.equals(old pkField): " +
pkField.equals(oldPkField));
}
}
I hope this helps.
Regards
--
Peter Vandoros
Software Engineer
Etech Group Pty Ltd
Level 3/21 Victoria St
Melbourne VIC 3000
Australia
Ph: +61 3 9639 9677
Fax: +61 3 9639 9577
----------------------------------
IMPORTANT: This e-mail message and any attachments are confidential and
may be privileged. If received in error, please reply to this message
and destroy all copies and any attachments. You should check this
message and any attachments for viruses or defects. Our liability is
limited to resupplying any affected message or attachments. For more
information about Etech Group, please visit us at
http://www.etechgroup.com.au.
_______________________________________________
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