db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Russell Simpkins" <RussellSimpk...@funnygarbage.com>
Subject RE: Foreign key relationships
Date Thu, 24 Apr 2003 15:55:39 GMT
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"/>

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


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.


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

View raw message