• 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: Snapshot problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Snapshot problems


  • Subject: Re: Snapshot problems
  • From: Chuck Hill <email@hidden>
  • Date: Thu, 19 Apr 2007 21:52:28 -0700


On Apr 19, 2007, at 9:45 PM, Peter Vandoros wrote:

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.recordChangesInEditingConte xt(EODatabaseContext.java:6059)
at com.webobjects.eocontrol.EOObjectStoreCoordinator.saveChangesInEditin gContext(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.

That would definitely do it (and may be what I am thinking of), though I would expect the error to happen all the time. This can happen if EOF is somehow generating Integer primary keys, but converting them into Long values when they are fetched. I have also see this happen with BigDecimal primary keys when the scale differed.


Mark: try printing the class of the PK for a newly created KitQuantity and for one fetched from the database. Are they the same?

Is EO inheritance involved here at all?

Chuck




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:
40global-village.net


This email sent to email@hidden


--

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      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Snapshot problems (From: Steven Mark McCraw <email@hidden>)
 >Re: Snapshot problems (From: Chuck Hill <email@hidden>)
 >Re: Snapshot problems (From: Steven Mark McCraw <email@hidden>)
 >Re: Snapshot problems (From: Chuck Hill <email@hidden>)
 >Re: Snapshot problems (From: Steven Mark McCraw <email@hidden>)
 >Re: Snapshot problems (From: Chuck Hill <email@hidden>)
 >Re: Snapshot problems (From: Steven Mark McCraw <email@hidden>)
 >Re: Snapshot problems (From: Peter Vandoros <email@hidden>)

  • Prev by Date: Re: Snapshot problems
  • Next by Date: Help: a boolean attribute always saves as null
  • Previous by thread: Re: Snapshot problems
  • Next by thread: Re: Snapshot problems
  • Index(es):
    • Date
    • Thread