You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by "Hartwig, Thomas" <t....@crapoud.com> on 2004/01/21 12:08:14 UTC

n-to-n relationship howto

Hello,

I'm sure there are a lot of users already needed a n-to-n relationship 
solution. Does Torque support this with a useable modell or do I have to 
implement this. I have looked thru the docs but all I found was: 1-to-n

Schema suggestion with a n-to-n relation, but this is not enough I'm afraid:

     <table name="A" description="Table">
         <column name="id"
             autoIncrement="true"
             required="true"
             primaryKey="true"
             type="BIGINT"/>
     </table>
     <table name="B" description="Table">
         <column name="id"
             autoIncrement="true"
             required="true"
             primaryKey="true"
             type="BIGINT"/>
     </table>

     <table name="A_B" description="Table">
         <column name="id"
             autoIncrement="true"
             required="true"
             primaryKey="true"
             type="BIGINT"/>
         <column
             name="A_id"
             type="BIGINT"/>
         <column
             name="B_id"
             type="BIGINT"/>
         <foreign-key foreignTable="A">
             <reference
                 local="A_id"
                 foreign="id"/>
         </foreign-key>
         <foreign-key foreignTable="B">
             <reference
                 local="B_id"
                 foreign="id"/>
         </foreign-key>
     </table>


Thanks for attention
Greetings
Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Re: n-to-n relationship howto

Posted by "Hartwig, Thomas" <t....@crapoud.com>.
Ok, I found the solution. I have seen that Torque does generate the 
methods getABs() in both BaseA and BaseB which returns the approbiate 
collection which then contains the methods getA() and getB().

Thomas


Hartwig, Thomas wrote:
> Hello,
> 
> I'm sure there are a lot of users already needed a n-to-n relationship 
> solution. Does Torque support this with a useable modell or do I have to 
> implement this. I have looked thru the docs but all I found was: 1-to-n
> 
> Schema suggestion with a n-to-n relation, but this is not enough I'm 
> afraid:
> 
>     <table name="A" description="Table">
>         <column name="id"
>             autoIncrement="true"
>             required="true"
>             primaryKey="true"
>             type="BIGINT"/>
>     </table>
>     <table name="B" description="Table">
>         <column name="id"
>             autoIncrement="true"
>             required="true"
>             primaryKey="true"
>             type="BIGINT"/>
>     </table>
> 
>     <table name="A_B" description="Table">
>         <column name="id"
>             autoIncrement="true"
>             required="true"
>             primaryKey="true"
>             type="BIGINT"/>
>         <column
>             name="A_id"
>             type="BIGINT"/>
>         <column
>             name="B_id"
>             type="BIGINT"/>
>         <foreign-key foreignTable="A">
>             <reference
>                 local="A_id"
>                 foreign="id"/>
>         </foreign-key>
>         <foreign-key foreignTable="B">
>             <reference
>                 local="B_id"
>                 foreign="id"/>
>         </foreign-key>
>     </table>
> 
> 
> Thanks for attention
> Greetings
> Thomas
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org

-- 
Firma Thomas Hartwig                        Telefon: 030-69599727
Software & IT-Service Spezialisten                www.crapoud.com
Boppstr. 11                                     Fax: 030-69599726
D-10967 Berlin                              GnuPG/PGP: 0xC51B523B

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org