Programming__WebObjects-EOF-Using EOF-Breaking EOF

Version 12.1 by smmccraw on 2007/07/08 10:30

You may be seeing problems like these in your application:


I've run into a rather nasty little problem after making some changes to my app recently. The problem never showed in testing and is difficult to contrive (which is the nasty bit). After an arbitrary and large number of requests, an arbitrary and small proportion of fetches fail. That is to say that some fetches give an object whose properties are all null. For example I wish to fetch a Member with username 'x'. I use a named EOFetchSpecification, specify the qualifier bindings and fetch my EOs.

EOFetchSpecification fetchSpec = EOFetchSpecification.fetchSpecificationNamed("usernameFetchSpec", "Member");
fetchSpec = fetchSpec.fetchSpecificationWithQualifierBindings(new NSDictionary("x", "usernameValue"));
NSArray results = ec.objectsWithFetchSpecification(fetchSpec);

I most cases I receive the expected results, but in some the first Member object in the NSArray has a null username, password, etc.


java.lang.IllegalStateException: Encountered a newly inserted EO with an owns destination relationship but no snapshot.
java.lang.IllegalStateException: Encountered a newly inserted EO with an owns destination relationship but no snapshot.
 at com.webobjects.eocontrol.EOEditingContext.processOwnedObjects(EOEditingContext.java:2150)
 at com.webobjects.eocontrol.EOEditingContext.
processDeletedObjects(EOEditingContext.java:2192)
 at com.webobjects.eocontrol.EOEditingContext.processRecentChanges(EOEditingContext.java:1744)
 at com.webobjects.eocontrol.EOEditingContext.processRecentChanges(EOEditingContext.java:1951)
 at com.webobjects.eocontrol.EOEditingContext.
processObjectStoreChanges(EOEditingContext.java:3536)


java.lang.IllegalStateException: rowDiffsForAttributes: snapshot in com.webobjects.eoaccess.EODatabaseOperation {
dbSnapshot = {};
...
this = "<com.foo.bar.DownloadLog a849b0 
EOIntegralKeyGlobalIDLong)0>"; }";
globalID = EOIntegralKeyGlobalIDLong)0;
databaseOperator = "EODatabaseUpdateOperator"; }
does not contain value for attribute named downloadDate with snapshot key: downloadDate

The stack trace is:
 at com.webobjects.eoaccess.EODatabaseOperation.rowDiffsForAttributes(EODatabaseOperation.java:338)
 at com.webobjects.eoaccess.EODatabaseContext.createAdaptorOperationsForDatabaseOperationAttributes(EODatabaseContext.java:5373)
 at com.webobjects.eoaccess.EODatabaseContext.createAdaptorOperationsForDatabaseOperation(EODatabaseContext.java:5548)
 at com.webobjects.eoaccess.EODatabaseContext.performChanges(EODatabaseContext.java:6365)
 at com.webobjects.eocontrol.EOObjectStoreCoordinator.saveChangesInEditingContext(EOObjectStoreCoordinator.java:415)
 at com.webobjects.eocontrol.EOEditingContext.saveChanges(EOEditingContext.java:3226)
 at net.globalvillage.eofextensions.ForgetfulEC.saveChanges(ForgetfulEC.java:54)
 at net.global
village.eofvalidation.EOEditingContext.saveChanges(EOEditingContext.java:126)
 at net.globalvillage.eofvalidation.NotifyingEditingContext.saveChanges(NotifyingEditingContext.java:159)

The exception is correct, the snapshot dbSnapshot = {}; does not contain any values, let alone the one it is looking for.  I am not completely sure of how this happens.  It is not consistent .


If you want to know the cause of these, go look in a mirror!  EOF is not broken, you are abusing it and it is fighting back.  Here is what to check: