db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Weber, Nadja" <Nadja.We...@telekom.de>
Subject AW: Foreign key relationships
Date Fri, 25 Apr 2003 09:00:40 GMT
yes, i have used the foreign key. what i have noticed is, that if i have a relationship  to
another table, i get a method getForeignKeys which returns a list as you wrote. but somehow
this method isn't generated when the foreign key is used within the same table. i guess i'll
have to code that myself. 

anyway, thanks for your reply

regards
nadja

-----Urspr√ľngliche Nachricht-----
Von: Russell Simpkins [mailto:RussellSimpkins@funnygarbage.com]
Gesendet: Donnerstag, 24. April 2003 17:56
An: Turbine Torque Users List
Betreff: RE: Foreign key relationships


have you used the foreign-key entity in your xml schema? i.e.

<table name="users" javaName="Users">
<column name="user_id" javaName="UserId" primaryKey="true" required="true" type="NUMERIC"
size="12" />
<column name="parent_id" javaName="ParentId" type="NUMERIC" size="12" />
<foreign-key foreignTable="users" onDelete="cascade">
	<reference local="parent_id" foreign="user_id"/>
</foreign-key>
</table>

This works for me.  However, I have not tried to make a column in my table be a foreign-key
to the table though.  I have used it mapping many to many and i get method from torque like
getMapTableEntries() that return a list of maptables.



-----Original Message-----
From: Eric Emminger [mailto:eric@ericemminger.com]
Sent: Thursday, April 24, 2003 11:49 AM
To: Turbine Torque Users List
Subject: Re: Foreign key relationships


Nadja

Weber, Nadja wrote:
> Hi all,
> 
> i have a question regarding usage of foreign key relationships in torque.
> I have a table of elements. Each of those elements has one foreign key reference to another
element (parent element) of the same table, thereby establishing a parent-child-hierarchy.
Now, while it's easy to retrieve the parent, what would i do to retrieve all children of an
element? At the moment i think of writing a select with the criteria set to the parents id,
but is there any other, built-in, functionality in torque that would let me get those relationships?

I don't think Torque generates any methods for getting children. At 
least, Torque hasn't done this for me, so that's my guess. I'm sure you 
could add this, however.

The easiest solution is probably to add such a method to your Element class.

Eric


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


---------------------------------------------------------------------
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