db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sheng Guo <sh...@in.tum.de>
Subject Re: torque delete
Date Thu, 25 Mar 2004 11:33:50 GMT
Hi,

Thanks for all of your advice, perhaps Siegfried is right, that I had a 
"*" in the xml file, now I am going to correct it, and try it again.

To Kostya:  I had the similar code, except for that, I specified only 
one primary key for the object of the  relation table, and I didn't 
write  savesys.setNew(false); before I tried to delete that object.  
Thanks a lot for your advice and your code. I think it should work now.

yours sincerely

Guo

Kostyantyn Shchekotykhin wrote:

> Hi Sheng,
> i've created a schema and a test case and all works fine. Here they are:
>
>     public void testDelete() throws Exception{
>         SYSContact cont = new SYSContact();
>         cont.setData(123);
>         SYSContactPeer.doInsert(cont);
>
>         SYSContactCategory contCat = new SYSContactCategory();
>         contCat.setData(321);
>         SYSContactCategoryPeer.doInsert(contCat);
>
>         Criteria criteria = new Criteria();
>         
> criteria.add(SYSContactCategory2SYSContactPeer.SYS_CONTACT_CATEGORY_ID, 
> contCat.getId());
>         criteria.add(SYSContactCategory2SYSContactPeer.SYS_CONTACT_ID, 
> cont.getId());
>         SYSContactCategory2SYSContactPeer.doInsert(criteria);
>
>         SYSContactCategory2SYSContact savesys = new 
> SYSContactCategory2SYSContact();
>         savesys.setSYSContactCategory(contCat);
>         savesys.setSYSContact(cont);
>         savesys.setNew(false);
>         SYSContactCategory2SYSContactPeer.doDelete(savesys);
>
>     }
>
>    <table name="sys_contact_category2sys_contact" 
> javaName="SYSContactCategory2SYSContact">
>        <column name="sys_contact_id" primaryKey="true" required="true" 
> type="BIGINT"/>
>        <column name="sys_contact_category_id" primaryKey="true" 
> required="true" type="BIGINT"/>
>        <foreign-key foreignTable="sys_contact">
>            <reference foreign="id" local="sys_contact_id"/>
>        </foreign-key>
>        <foreign-key foreignTable="sys_contact_category">
>            <reference foreign="id" local="sys_contact_category_id"/>
>        </foreign-key>
>    </table>
>
>    <table name="sys_contact" javaName="SYSContact">
>        <column name="id" primaryKey="true" required="true" 
> type="BIGINT"/>
>        <column name="data" required="true" type="BIGINT"/>
>    </table>
>
>    <table name="sys_contact_category" javaName="SYSContactCategory">
>        <column name="id" primaryKey="true" required="true" 
> type="BIGINT"/>
>        <column name="data" required="true" type="BIGINT"/>
>    </table>
>
> If the doDelete(Object) works then it will sure work with a Criteria 
> as a param.
>
> Regards,
> Kostya
>
> Sheng Guo wrote:
>
>> Hi,
>>
>> This try failed,  I got the same error message:
>>
>> org.apache.torque.TorqueException: You must specify KeyDef attributes 
>> for this TableDataSet in order to delete a Record.
>>
>> I added the code, which is bold, in the XML-Schema file:
>>
>> <table name="sys_contact_category2sys_contact" 
>> javaName="SYSContactCategory2SYSContact">
>>        <column name="sys_contact_id" *primaryKey="true" 
>> *required="true" type="BIGINT"/>
>>        <column name="sys_contact_category_id"* primaryKey="true"* 
>> required="true" type="INTEGER"/>
>>        <foreign-key foreignTable="sys_contact">
>>            <reference foreign="id" local="sys_contact_id"/>
>>        </foreign-key>
>>        <foreign-key foreignTable="sys_contact_category">
>>            <reference foreign="id" local="sys_contact_category_id"/>
>>        </foreign-key>
>>    </table>
>>
>> The peer classes were successfully created, but the problem was not 
>> solved. Did I do anything wrong with the XML-Schema?
>>
>> Thanks
>>
>> Guo
>>
>>
>>
>> Sheng Guo wrote:
>>
>>> Hi,
>>>
>>> Thanks for this advice, actually the relation table doesn't have any 
>>> primary keys, it has only two foreign keys from the other two 
>>> tables. Now I am trying to fix the XML-Schema, so that the foreign 
>>> keys in the relation table are also primary keys. I don't know, if 
>>> it will work, but I'll try it, and let you know.
>>>
>>> Thanks a lot
>>>
>>> Guo
>>>
>>> Kostyantyn Shchekotykhin wrote:
>>>
>>>> Hi Sheng,
>>>> KeyDef means primary key. It says to you that the primary key of 
>>>> the table was not found and Torque is unable to identify records to 
>>>> delete. If you'll poste some details, i'll try to help you more.
>>>>
>>>> Regards,
>>>> Kostya
>>>>
>>>> Sheng Guo wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I am a new user of Torque, and I tried to delete some records from 
>>>>> a relation table ( which holds the n:m relation of the other two 
>>>>> tables), but it failed,
>>>>>
>>>>> the exception said:
>>>>>
>>>>> org.apache.torque.TorqueException: You must specify KeyDef 
>>>>> attributes for this TableDataSet in order to delete a Record.
>>>>>
>>>>> what does it mean, and how can I specify KeyDef attributes?
>>>>>
>>>>> Thanks
>>>>>
>>>>> Guo
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
>>>>> For additional commands, e-mail: torque-user-help@db.apache.org
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
>>>> For additional commands, e-mail: torque-user-help@db.apache.org
>>>>
>>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: torque-user-help@db.apache.org
>>>
>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: torque-user-help@db.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message