You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Ben Peter <bp...@zentropypartners.com> on 2002/03/31 09:00:03 UTC

Torque: self-referring tables/objects

All,

has anyone used Torque with self-referring tables?

In the tutorial example, if I have two tables, book and author, which are 
related n:1, I can call book.getAuthor() and get an Author object back.

If, however, I have a foreign-key that refers back to the same table:

<table name="NODE" idMethod="idbroker">
     <column name="NODE_ID" required="true" type="BIGINT" primaryKey="true"/>
     <column name="PARENT_NODE" required="false" type="BIGINT"/>
     <foreign-key foreignTable="NODE">
         <reference local="PARENT_NODE" foreign="NODE_ID"/>
     </foreign-key>
</table>

these relationships will not be setup. Why is this so, or is it intended at all?

I have tried to work around this by not using the <foreign-key/>. However, I 
end up trying to
node.setParentNode(parent.getPrimaryKeyAsLong());
using deprecated methods.

Or should this read
node.setParentNode(parent.getNodeId().getBigDecimal().getLongValue());
 From the javadocs this looks correct, but I cannot claim to know the semantics 
of NumberKey.

Any help is appreciated.
Cheers,
Ben


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>