You can add the foreign key definition in the schema. Look at the
element:reference in
http://jakarta.apache.org/turbine/torque/schema-reference.html

I think it would work just by creating the join in the criteria but if you
add the reference
it will add some methods that would make it easier and it will create the
foreign key definitions
in the .sql that creates the tables.
--
  Humberto

-----Original Message-----
From: Eigen Technology Pty Ltd [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 20, 2003 1:00 AM
To: [EMAIL PROTECTED]
Subject: Re: Foreign Key


Thanks,

>From what you have suggested, I don't have to add Foreign Keys to these
fields in my sechma file? All is needed is just a join criterial in my
.java file.

thanks
michael



> Hi Michael,
>
> I'm guessing you're trying to get the data from Table 2.  So the
> following would be all that's required (I think):
>
> Criteria criteria = new Criteria();
> criteria.add(Table1Peer.ID, <your constraint here>);
> criteria.addJoin(Table1Peer.ID, Table2Peer.Col_C);
> criteria.addJoin(Table1Peer.ID, Table2Peer.Col_D);
>
> List result = Table2Peer.doSelect(criteria);
>
> HTH,
> CP
>
>
> Eigen Technology Pty Ltd wrote:
>> Hi...
>>
>> If a table has two columns which are related to another table, can I
>> Join them using Foreign Key, if so, how could I do it?
>>
>> Table 1
>> ID
>> Col_A
>> Col_B
>>
>> Table 2
>> ID
>> Col_C   <----  need to link to ID in table_1
>> Col_D   <----  also need to link to ID in table_1
>>
>> thanks
>> michael
>>
>>
>>
>> --
>> To unsubscribe, e-mail:
>> <mailto:[EMAIL PROTECTED]> For
>> additional commands, e-mail:
>> <mailto:[EMAIL PROTECTED]>
>>
>>
>>
>
>
> --
> R E D S H E R I F F
> C.P. Lim - Software Engineer
> Level 1, 10 Queens Road    +61 3 9864 0733 tel
> Melbourne VIC              +61 3 9864 0778 fax
> Australia                  +61 413 781 846 mob
>
> This message and any files transmitted with it are confidential and
> intended solely for the use of the individual or entity to whom they are
>  addressed. If you are not the intended recipient, you are hereby
> notified that any use or dissemination of this communication is strictly
>  prohibited. If you have received this message in error please notify us
>  immediately by return email or telephone +61 (3) 9659 0432, then delete
>  this message. Any views expressed in this message are those of the
> individual sender and many not necessarily reflect the views of Red
> Sheriff.
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]> For
> additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>




--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to