Hi,
You use the foreign keys also as primary key. In my experience, using something which has another meaning as a primary key is not a good idea. Can you try to add another column, e.g. user_role_id, as a primary key,
remove the primaryKey attribute from the other columns and try it again ?
Just removing the primaryKey attribute is also not a good idea, as Torque relies on having a primary key.
Just a comment on your secondary problem (building the query by hand). Looking at the source code, executeStatement is plain jdbc, just using Torque's connection pool to execute your query. So I am very amazed that this does not work. Did you look at the return value of executeStatement ?
It should give you the number of affected rows. If it is > 0 but you still see the row you just deleted, then maybe it is a transaction problem (not enough commits). Perhaps(if you use several databases at once), the command might hit the wrong database
Thomas
On Tue, 8 Mar 2005, Dave Newton wrote:
Hola,
I'm at my wit's end.
I'm trying to delete a record from a table that has three foreign keys (schema fragment attached) and it seems no matter how I try to do it I either get the "You must specify KeyDef attributes for this TableDataSet in order to delete a Record" exception. It's a MySQL db, using Torque 3.1.
Fragment:
<table name='user_role' description='Map of users to user roles and events'>
<column name='role_name' size='32' type='VARCHAR' description='FKEY role_name' required='true' primaryKey="true"/>
<column name='user_id' type='INTEGER' description='FKEY User ID' required='true' primaryKey="true"/>
<column name='event_id' type='INTEGER' description='FKEY Event ID' required='true' primaryKey="true"/>
<foreign-key foreignTable='event'>
<reference local='event_id' foreign='event_id'/>
</foreign-key>
<foreign-key foreignTable='role'>
<reference local='role_name' foreign='role_name'/>
</foreign-key>
<foreign-key foreignTable='user'>
<reference local='user_id' foreign='user_id'/>
</foreign-key>
</table>
Whether I have the 'primaryKey' attributes in there or not it doesn't work using doDelete with Criteria or a matching object.
So I build the SQL myself and do an executeStatement, which fails silently, deleting nothing. I cut and paste the query into a MySQL query browser and it works fine, naturally.
Where am I going wrong? I searched the archives and found this question but no answer, including the following not-so-helpful wiki entry: http://wiki.apache.org/db-torque/TorqueProjectPages/FAQ down at the bottom.
Hep me! Hep me! I've been using torque for years (no, really!) and never had this issue before whether by accident or design.
Thanks, Dave
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
