• 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: Attempt to generate SQL failed
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Attempt to generate SQL failed


  • Subject: Re: Attempt to generate SQL failed
  • From: Chuck Hill <email@hidden>
  • Date: Thu, 15 Sep 2005 11:01:07 -0700

Hi Ian,


On Sep 14, 2005, at 9:04 PM, Ian Joyner wrote:

Looks like this is still a bug in WO. To summarize, I have an entity called Asset, which had a relationship test_results to entity Test_result. Test_result is abstract and the real result is in subclass entities Graded_result and Value_result.

When you look in EOModeler, is there a relationship from Test_result back to Asset? Does this relationship also appear on Graded_result and Value_result? It sounds like you may not have added it to all of the entities.

I removed the relationship test_results from Asset and replace it with graded_results and value_results. I had to do a little bit of code to reconstitute the graded and value results into one array, but indeed using this scheme worked.

Is this a known WO bug? Has someone already submitted it to Apple?

Even if they have submitted it, you should do it again. The more submissions against a bug the more likely it is to get fixed.



Chuck


On 14/09/2005, at 5:19 PM, Ian Joyner wrote:

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._exceptionWithDatabaseConte xtInformationAdded(EODatabaseContext.java:4686)
at com.webobjects.eoaccess.EODatabaseContext.performChanges (EODatabaseContext.java:6394)
at com.webobjects.eocontrol.EOObjectStoreCoordinator.saveChangesInEditin gContext(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

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40sportstec.com


This email sent to email@hidden

_______________________________________________
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 - a book for intermediate WebObjects developers who want to increase their overall knowledge of WebObjects, or those who are trying to solve specific application development 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: 
 >Attempt to generate SQL failed (From: Ian Joyner <email@hidden>)
 >Re: Attempt to generate SQL failed (From: Ian Joyner <email@hidden>)

  • Prev by Date: Re: strange EO error
  • Next by Date: Re: Attempt to generate SQL failed
  • Previous by thread: Re: Attempt to generate SQL failed
  • Next by thread: Xcode is garbage!
  • Index(es):
    • Date
    • Thread