db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Schmitt" <mich...@popfrontal.de>
Subject foreign-key: how to reference two fields?
Date Tue, 15 Apr 2003 12:01:21 GMT
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


Mime
View raw message