Here's something else puzzling about my problem. If I add something else attached to Asset, then do the save, it updates the Test_results fine and updates the Person (parent class of Asset) setting the modification date. The interesting thing is that in the Person update, it uses 'NeededByEOF0' to set the binding for PRIMARY_KEY:
I have just managed to break some code which has been working for some time. I have narrowed it down to a line on the server side as follows:
public void awakeFromClientUpdate (EOEditingContext ec) {
super.awakeFromClientUpdate (ec);
// setModification_date (new NSTimestamp ());
}
The commented out line causes the failure, and what has happened is that I have added a set of 'test' (not programming tests) entities which get attached to an Asset entity. So Asset sees its Test_results from a one-to-many relationship:
test_results: Asset (primary_key) --> Test_result (asset_key)
Now Test_result is abstract and has subclasses Graded_result and Value_result. I add a set of these, setting their asset_key (in class Test_result) as follows:
public void initialize (Skills_test its_test, Asset for_asset, Test_result parent_result) {
setTest (its_test);
setAsset (for_asset);
addObjectToBothSidesOfRelationshipWithKey (for_asset, "asset");
for_asset.addObjectToBothSidesOfRelationshipWithKey (this, "test_results");
setParent_test (parent_result);
setDate (new NSTimestamp ());
}
I should only need one addObjectToBothSidesOfRelationshipWithKey, but I tried both combinations just to make sure.
When I do an editingContext.saveChanges (), all of the Graded_results are stored fine, but the last thing it tries to do is to update the modification date on Asset, but at this point I get:
[2005-09-14 16:43:39 EST] <WorkerThread11> evaluateExpression: <com.webobjects.jdbcadaptor.OpenBasePlugIn$OpenBaseExpression: "INSERT INTO GRADED_TEST_RESULT(ASSET_KEY, NOTES, GRADE_KEY, PRIMARY_KEY, PARENT_TEST_KEY, TEST_KEY, DATE) VALUES (?, NULL, ?, ?, ?, ?, ?)" withBindings: 1:5(asset_key), 2:5(grade_key), 3:129(primary_key), 4:133(parent_test_key), 5:19(test_key), 6:2005-09-14 16:43:17(date)>
[2005-09-14 16:43:39 EST] <WorkerThread11> === Rollback Internal Transaction
[2005-09-14 16:43:39 EST] <WorkerThread11> Server exception: sqlStringForKeyValueQualifier: attempt to generate SQL for com.webobjects.eocontrol.EOKeyValueQualifier (NeededByEOF0 = 5) failed because attribute identified by key 'NeededByEOF0' was not reachable from from entity 'Asset'
[2005-09-14 16:43:39 EST] <WorkerThread11> com.webobjects.eoaccess.EOGeneralAdaptorException: sqlStringForKeyValueQualifier: attempt to generate SQL for com.webobjects.eocontrol.EOKeyValueQualifier (NeededByEOF0 = 5) failed because attribute identified by key 'NeededByEOF0' was not reachable from from entity 'Asset'
at com.webobjects.eoaccess.EODatabaseContext._exceptionWithDatabaseContextInformationAdded(EODatabaseContext.java:4686)
at com.webobjects.eoaccess.EODatabaseContext.performChanges(EODatabaseContext.java:6394)
at com.webobjects.eocontrol.EOObjectStoreCoordinator.saveChangesInEditingContext(EOObjectStoreCoordinator.java:415)
at com.webobjects.eocontrol.EOEditingContext.saveChanges(EOEditingContext.java:3187)
at com.webobjects.eodistribution.EODistributionContext$_RemoteMethodReceiver.clientSideRequestSave(EODistributionContext.java:1071)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Now the NeededByEOF0 = 5 refers to the Asset's primary_key (in fact I manually changed it from 3 to 5 in the database and sure enough the value changed here). I think the relationships are right because problems there usually result in an 'unable to generate SQL' on an _EOFinv.<realtionship path> key, but I have a problem on NeededByEOF0, so it looks like Asset is having a problem referencing itself.
I know that NeededByEOF0 is an internal thing in EOF, but why is it using it here, instead of PRIMARY_KEY?
I have been through the model with a fine-tooth comb, and everything looks alright, but what could I be missing.
I even removed the 'abstract' from Test_result java class (like last weeks Skills_test problem), but that did not work.
I have seen some problems mentioned in past posts that there could be a bug in EOF with relationships that reference an abstract type with subclasses. Is this still the case and hence my problem?
Any insights most welcome
Thanks
Ian Joyner
Sportstec