Re: Attempt to generate SQL failed
Re: Attempt to generate SQL failed
- Subject: Re: Attempt to generate SQL failed
- From: Guido Neitzer <email@hidden>
- Date: Thu, 15 Sep 2005 23:00:10 +0200
There is another bug on that, if I remember correctly: if you add an
attribute to the base class, it is added to the subclasses, but not
checked to be a class property ... (Don't have this good enough in my
memory to describe it better or to be sure about it.)
cug
On 15.09.2005, at 20:03 Uhr, Chuck Hill wrote:
Looks like maybe missing back pointing relationships. Adding
relationships to base classes after subclasses have been created
does not add them to the subclasses (EOModeler bug).
Chuck
On Sep 14, 2005, at 6:48 PM, Ian Joyner wrote:
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:
[2005-09-15 11:37:57 EST] <WorkerThread7> evaluateExpression:
<com.webobjects.jdbcadaptor.OpenBasePlugIn$OpenBaseExpression:
"INSERT INTO BODY_METRICS(ASSET_KEY, NOTES, LEG_LENGTH,
PRIMARY_KEY, THIGH_MEASURE, BICEP_MEASURE, HEIGHT, PROTOCOL,
ARM_LENGTH, DATE, WAIST) VALUES (?, NULL, ?, ?, ?, ?, ?,
NULL, ?, ?, ?)" withBindings: 1:5(asset_key), 2:0(leg_length), 3:4
(primary_key), 4:0(thigh_measure), 5:0(bicep_measure), 6:0
(height), 7:0(arm_length), 8:2005-09-15 11:37:53(date), 9:0(waist)>
[2005-09-15 11:37:57 EST] <WorkerThread7> evaluateExpression:
<com.webobjects.jdbcadaptor.OpenBasePlugIn$OpenBaseExpression:
"UPDATE PERSON SET MODIFICATION_DATE = ? WHERE (PRIMARY_KEY = ?
AND UNIQUE_ID is NULL AND TYPE = ? AND TITLE_KEY = ? AND
TERMINATION_DATE is NULL AND SURNAME = ? AND PERSON_TYPE_KEY = ?
AND MODIFICATION_DATE = ? AND MIDDLE_NAMES is NULL AND GENDER_KEY
= ? AND FIRST_NAME = ? AND DATE_OF_BIRTH is NULL AND CREATION_DATE
= ? AND ALIAS = ?)" withBindings: 1:2005-09-15 11:37:57
(modification_date), 2:5(NeededByEOF0), 3:"A"(type), 4:1
(title_key), 5:"Lincoln"(surname), 6:12(person_type_key),
7:2005-09-15 10:33:41(modification_date), 8:6(gender_key),
9:"Abraham"(first_name), 10:2005-09-14 15:40:09(creation_date),
11:"Abe"(alias)>
Can anyone give any direction as to what to check to fix this?
Thanks
Ian
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._exceptionWithDatabaseCont
extInformationAdded(EODatabaseContext.java:4686)
at com.webobjects.eoaccess.EODatabaseContext.performChanges
(EODatabaseContext.java:6394)
at
com.webobjects.eocontrol.EOObjectStoreCoordinator.saveChangesInEditi
ngContext(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:
40pharmaline.de
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:
This email sent to email@hidden