db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Broadhead <robbroadh...@mindspring.com>
Subject Re: How do I use the feature onUpdate="cascade" with Torque?
Date Thu, 04 Mar 2004 16:15:21 GMT
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


Mime
View raw message