You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Sheng Guo <sh...@in.tum.de> on 2004/03/24 18:01:57 UTC

torque delete

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


Re: torque delete

Posted by Gary Shea <sh...@gtsdesign.com>.
My experience is you get that error if the table has no primary key or
if torque's schema doesn't include the primary key.  Only the per-column
primaryKey= attribute will help; the index and unique sub-elements of
<table> have no effect on this problem.  If you have a multi-part
primary key, you can put a primaryKey= attribute in each of the <column>
elements.

Hope that helps...

        Gary

On Wed, 24 Mar 2004, at 18:01 [+0100], Sheng Guo (sheng@in.tum.de) 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


Re: Torque and XSLT

Posted by Emmanuel Florent <ef...@formaguide.com>.
Try to do 5% of the torque-gen features with XSLT and then ask question
again :)
It is such a good design that some here could have extended by doing a
kind of phpmyadmin, but custom for your model, 
One, Bogdan, could have do it in JSP, and I'm actually doing it in PHP,
using a Model2/MVC framework and some part of phplib for extending an
application for a customer. Velocity Template Language Rocks !

Emmanuel Florent
http://www.devaki.org/


On Thu, 2004-03-25 at 14:18, Alexandru Dovlecel wrote:
> Hello all,
> 
> I do have a question, plain curriosity, I think will not help me in the
> development of my projects. Why torque_gen is using velocity templates? Why
> not using XSLT transformations? Is there a good reason or only because the
> torque was part of the turbine framework (AFAIK)?
> 
> Does it mean that Velocity provides extra functionality compared to XSLT?
> 
> I am asking those questions because the schema is defines in XML, so an XSLT
> transformation was the first thing that was on my mind.
> 
> Sorry for flooding the mailing list with such nonsense. :((( But it's about
> the curiosity.
> 
> Thanks,
> Alex
> 
> 
> ---------------------------------------------------------------------
> 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


Torque and XSLT

Posted by Alexandru Dovlecel <al...@siemens.com>.
Hello all,

I do have a question, plain curriosity, I think will not help me in the
development of my projects. Why torque_gen is using velocity templates? Why
not using XSLT transformations? Is there a good reason or only because the
torque was part of the turbine framework (AFAIK)?

Does it mean that Velocity provides extra functionality compared to XSLT?

I am asking those questions because the schema is defines in XML, so an XSLT
transformation was the first thing that was on my mind.

Sorry for flooding the mailing list with such nonsense. :((( But it's about
the curiosity.

Thanks,
Alex


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


Re: torque delete

Posted by Sheng Guo <sh...@in.tum.de>.
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


Re: torque delete

Posted by Kostyantyn Shchekotykhin <ko...@ifit.uni-klu.ac.at>.
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


RE: torque delete

Posted by Alexandru Dovlecel <al...@siemens.com>.
If you refer to the mail I have just sent, then:

The questions I have asked are generic. Not a specific implementation.

The table I want to delete entries from has no primary key and was created
to normalise a Many To Many relation.

The question: is it recommended to use criteria to delete entries in this
table, or works faster if passing objects to the delete method? Is there any
performance drawback for those approaches?

alex

> -----Original Message-----
> From: Sipe Informatica [mailto:desarrollo@sipeinformatica.com]
> Sent: Thursday, March 25, 2004 11:13 AM
> To: Apache Torque Users List
> Subject: Re: torque delete
>
>
> Wich database are you using? Wich method for primarykeys have
> you set?
> idbroker or native?
>
> ---------------------------------------------------------------------
> 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


Re: torque delete

Posted by Sipe Informática <de...@sipeinformatica.com>.
Wich database are you using? Wich method for primarykeys have you set? 
idbroker or native?

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


Re: torque delete

Posted by Sheng Guo <sh...@in.tum.de>.
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


Re: torque delete

Posted by Sheng Guo <sh...@in.tum.de>.
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


Re: torque delete

Posted by Kostyantyn Shchekotykhin <ko...@ifit.uni-klu.ac.at>.
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