db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tomasz Dre├čler <tdr...@terragate.net>
Subject Re: How do I use the feature onUpdate="cascade" with Torque?
Date Thu, 04 Mar 2004 17:01:21 GMT
Hi Rob Broadhead.
I use Mysql witch allow to change PK.
I don't get a SQL exception. Torqe do a "select from server where 
server.serveradress='newServerAdress'"
when I call server.setServeradress("newServerAdress").
Of corse, such server is not in Database so Torque do nothing.
In my code I don't do nothing.
I fetch a server object with server.getServeradress() -> 'oldServerAdress'.
And this object I would like to change in 
'server.setServeradress("newServerAdress")'.


In sql I would write this query:
update server set serveradress='newServerAdress' where 
serveradress='oldServerAdress'

\Tomek

Rob Broadhead wrote:

> Most databases don't allow the PK to be changed. You should be getting 
> a SQL exception along those lines. Also, in your example  you iterate 
> through the list of servers and don't do anything other than iterate 
> so I may not be understanding what you are attempting to do.
>
> Rob
>
> At 10:02 AM 3/4/2004, you wrote:
>
>> Hi!
>> I have the tables 'server' and 'file'.
>> How can I update the 'server.serveradress' (PK) and 
>> 'file.serverAdress' (FK) with Torque?
>> The attribute 'file.serverAdress' have the flag onUpdate="cascade".
>>
>> I try folowing:
>>    Criteria crit = new Criteria();
>>    crit.add(ServerPeer.SERVERADRESS, "oldServerAdress");
>>    List v = ServerPeer.doSelect(crit)
>>
>>    Iterator iteratorServer = v.iterator();
>>    Server server;
>>    if(iteratorServer.hasNext()){
>>            server = (Server) iteratorServer.next();
>>    }
>>
>>    server.setServeradress("newServerAdress");
>>
>>    ServerPeer.doUpdate(server);    // don't work
>>    server.save();                             // don't work, too
>>
>> Thanks for your attention
>>
>> Greetings Tomek
>>
>> [------------------------- schema.xml 
>> --------------------------------------]
>> <table name="server" description="Server Tabelle" idMethod="none">
>>   <column name="serverAdress" primaryKey="true"
>>       required="true" type="VARCHAR" size="255"
>>       description="Server Adresse"  />
>>   <column name="serverName"
>>     required="true" type="VARCHAR"
>>     size="128" description="Server Name" />
>> </table>
>>
>> <table name="file" description="File Tabelle" idMethod="native">
>>   <column name="fileId" required="true" primaryKey="true"
>>     type="INTEGER" autoIncrement="true"
>>     description="File ID" />
>>   <column name="serverAdress" required="true"
>>     type="VARCHAR" size="255"
>>     description="FK Server Adresse" />
>>   <column name="filePath" required="true"
>>     type="LONGVARCHAR"
>>     description="File Pfad" />
>>    <column name="fileName" required="true"
>>     type="VARCHAR" size="255"
>>     description="File Name" />
>>   <foreign-key foreignTable="server" onUpdate="cascade">
>>       <reference local="serverAdress" foreign="serverAdress"/>
>>   </foreign-key>
>> </table>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: torque-user-help@db.apache.org
>
>
> //--------------------------------------------------------------------
> Rob Broadhead - Consultant
> RB Consulting Inc.
> Rob@RB-SNS.com
> //--------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> 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