db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Malte Stien <ma...@stien.de>
Subject Multiple primary keys?
Date Thu, 05 Jun 2003 04:47:48 GMT
Hi

Does each table in Torque have to have exactly one primary key? I have a table 
(SimpleQuestion) where the primary identifiers (IssueID and ProjectElementID) 
are in fact a pair of foreign keys that reference another table. The 
referenced table (BasicQuestion) contains two columns whose values are not 
unique on their own but in combination they are.

I already tried to specify both columns (IssueID and ProjectElementID) as 
primaryKey=true. But unfortunately, that does not work. Torque generates an 
SQL-schema which is not valid for Postgresql.

In that case I would like to specify no primary key but specify that pair of 
columns in the referencing and the referenced table (SimpleQuestion and 
BasicQuestion) as unique and each of the two columns as not null 
(required=true) which according to the Postgresql user's guide should lead to 
the same result at least on the database level.

But Torque creates code that cannot be compiled by javac:
BaseSimpleQuestion.java:211: cannot resolve symbol
symbol  : method retrieveByPK (java.lang.Integer,java.lang.Integer)
location: class au.com.softimp.sodis.model.BasicQuestionPeer
aBasicQuestion = BasicQuestionPeer.retrieveByPK(this.issueid, 
this.projectelementid);

If anybody would have any ideas that would be highly appreaciated.
Regards,
Malte.

The schema of the involved two tables follows here:
<!-- ********************** BasicQuestion ********************** -->
  <table name="BasicQuestion" description="" idMethod="none">
    <column
      name="IssueID"
      required="true"
      type="INTEGER"
      description=""/>
    <column
      name="ProjectElementID"
      required="true"
      type="INTEGER"
      description=""/>
    <foreign-key foreignTable="Issue">
    <!-- ModelRelationShip R1 -->
      <reference
        local="IssueID"
        foreign="IssueID"/>
    </foreign-key>
    <foreign-key foreignTable="ProjectElement">
    <!-- ModelRelationShip R1 -->
      <reference
        local="ProjectElementID"
        foreign="ProjectElementID"/>
    </foreign-key>
    <unique>
        <unique-column name="ProjectElementID"/>
        <unique-column name="IssueID"/>
    </unique>
  </table>
<!-- ********************** SimpleQuestion ********************** -->
  <table name="SimpleQuestion" description="" idMethod="none">
    <column
      name="AnalysisDataItemID"
      required="true"
      type="INTEGER"
      description=""/>
    <column
      name="IssueID"
      required="true"
      type="INTEGER"
      description=""/>
    <column
      name="ProjectElementID"
      required="true"
      type="INTEGER"
      description=""/>
    <foreign-key foreignTable="BasicQuestion">
    <!-- ModelRelationShip R2 -->
      <reference
        local="IssueID"
        foreign="IssueID"/>
      <reference
        local="ProjectElementID"
        foreign="ProjectElementID"/>
    </foreign-key>
    <foreign-key foreignTable="Question">
    <!-- ModelRelationShip R4 -->
      <reference
        local="AnalysisDataItemID"
        foreign="AnalysisDataItemID"/>
    </foreign-key>
  </table>



Mime
View raw message