Wiki source code of EOF-Using EOF-Breaking EOF

Last modified by Maik Musall on 2011/10/03 01:26

Hide last authors
Pascal Robert 5.1 1 You may be seeing problems like these in your application:
2
Ray Kiddy 16.1 3 >//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.//
Pascal Robert 5.1 4
Pascal Robert 13.1 5 {{code}}
6
Pascal Robert 5.1 7 EOFetchSpecification fetchSpec = EOFetchSpecification.fetchSpecificationNamed("usernameFetchSpec", "Member");
8 fetchSpec = fetchSpec.fetchSpecificationWithQualifierBindings(new NSDictionary("x", "usernameValue"));
9 NSArray results = ec.objectsWithFetchSpecification(fetchSpec);
10
Pascal Robert 13.1 11 {{/code}}
Pascal Robert 5.1 12
Ray Kiddy 16.1 13 >//In most cases I receive the expected results, but in some the first Member object in the NSArray has a null username, password, etc.//
Pascal Robert 5.1 14
Ray Kiddy 17.2 15 {{noformat}}java.lang.IllegalStateException: Encountered a newly inserted EO with an owns destination relationship but no snapshot.
Pascal Robert 5.1 16 java.lang.IllegalStateException: Encountered a newly inserted EO with an owns destination relationship but no snapshot.
Pascal Robert 13.1 17 at com.webobjects.eocontrol.EOEditingContext._processOwnedObjects(EOEditingContext.java:2150)
18 at com.webobjects.eocontrol.EOEditingContext._processDeletedObjects(EOEditingContext.java:2192)
19 at com.webobjects.eocontrol.EOEditingContext._processRecentChanges(EOEditingContext.java:1744)
20 at com.webobjects.eocontrol.EOEditingContext.processRecentChanges(EOEditingContext.java:1951)
Ray Kiddy 17.2 21 at com.webobjects.eocontrol.EOEditingContext._processObjectStoreChanges(EOEditingContext.java:3536){{/noformat}}
Pascal Robert 5.1 22
Pascal Robert 13.1 23 {{noformat}}
24
Pascal Robert 5.1 25 java.lang.IllegalStateException: rowDiffsForAttributes: snapshot in com.webobjects.eoaccess.EODatabaseOperation {
Pascal Robert 13.1 26 _dbSnapshot = {};
Pascal Robert 5.1 27 ...
Pascal Robert 13.1 28 this = "<com.foo.bar.DownloadLog a849b0 _EOIntegralKeyGlobalID[DownloadLog (java.lang.Long)0]>"; }";
29 _globalID = _EOIntegralKeyGlobalID[DownloadLog (java.lang.Long)0];
30 _databaseOperator = "EODatabaseUpdateOperator"; }
31 does not contain value for attribute named downloadDate with snapshot key: downloadDate
Pascal Robert 5.1 32
33 The stack trace is:
Pascal Robert 13.1 34 at com.webobjects.eoaccess.EODatabaseOperation.rowDiffsForAttributes(EODatabaseOperation.java:338)
35 at com.webobjects.eoaccess.EODatabaseContext.createAdaptorOperationsForDatabaseOperationAttributes(EODatabaseContext.java:5373)
36 at com.webobjects.eoaccess.EODatabaseContext.createAdaptorOperationsForDatabaseOperation(EODatabaseContext.java:5548)
37 at com.webobjects.eoaccess.EODatabaseContext.performChanges(EODatabaseContext.java:6365)
38 at com.webobjects.eocontrol.EOObjectStoreCoordinator.saveChangesInEditingContext(EOObjectStoreCoordinator.java:415)
39 at com.webobjects.eocontrol.EOEditingContext.saveChanges(EOEditingContext.java:3226)
40 at net.global_village.eofextensions.ForgetfulEC.saveChanges(ForgetfulEC.java:54)
41 at net.global_village.eofvalidation.EOEditingContext.saveChanges(EOEditingContext.java:126)
42 at net.global_village.eofvalidation.NotifyingEditingContext.saveChanges(NotifyingEditingContext.java:159)
Pascal Robert 5.1 43
Pascal Robert 13.1 44 {{/noformat}}
45
Ray Kiddy 16.1 46 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 .
Pascal Robert 5.1 47
Ray Kiddy 16.1 48 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:
Pascal Robert 5.1 49
Maik Musall 19.1 50 * [[The EOF Commandments>>doc:documentation.Home.Development Architecture.EOF Architecture.EOF.EOF-Using EOF-The EOF Commandments.WebHome]]
Kieran Kelleher 18.1 51 * [[Context and Database Locking>>doc:documentation.Home.Development Architecture.EOF Architecture.EOF.EOF-Using EOF-Context and Database Locking.WebHome]]
Ray Kiddy 15.1 52
Ray Kiddy 16.1 53 (wikidiscard -> This information seems too specific and provides no context. I cannot think how looking in a mirror would be helpful. If someone finds this page because they are having a problem, what do they learn from this page? I think that they learn nothing. If there is a point to be made, it can be added to the information in the 'EOF Commandments' page or in some other more appropriate place. -rrk 2011/10/02.)