db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Schmitt" <mi.schm...@gmx.de>
Subject Re: foreign-key: how to reference two fields?
Date Tue, 15 Apr 2003 12:34:50 GMT
Sorry,
I just discovered that I forgot to declare both fields as primary keys.
No, it works.
bye,
michael


----- Original Message -----
From: "Michael Schmitt" <michael@popfrontal.de>
To: <torque-user@db.apache.org>
Sent: Tuesday, April 15, 2003 1:01 PM
Subject: foreign-key: how to reference two fields?


> Hi,
> I am wondering how to manage something like the following:
> I have got a table with some foreign key, but the key consists of two
> values.
> My table looks something like this:
>   <table name="band">
>     <column name="id" required="true"  type="INTEGER" primaryKey="true"/>
>     <column name="name" required="true"  type="VARCHAR" size="255"/>
>     <column name="origin_city" required="true" type="VARCHAR" size="255"/>
>     <column name="origin_country" required="true" type="VARCHAR"
> size="255"/>
>     <foreign-key foreignTable="city">
>       <reference local="origin_city" foreign="name"/>
>       <reference local="origin_country" foreign="country_name"/>
>     </foreign-key>
>   </table>
>
> To get a unique city, you need the city's name and its country.
> I am able to generate sourcecode, but I am unable to compile it.
> Torque generates something like the following in BaseBand.java:
> public City getCity() throws TorqueException{
>     ...
>     aCity = CityPeer.retrieveByPK(this.origin_city, this.origin_country);
>     ...
> }
>
> But there is no generated method 'retrieveByPK(String, String)' in
> BaseCityPeer.
> Do I have to write it on my own, and if so, how?
>
> bye,
> michael
>
>
> ---------------------------------------------------------------------
> 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