db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicolas Pottrain <npottr...@reference.be>
Subject Recursive foreign key : SQLException
Date Tue, 17 Jun 2003 08:28:04 GMT
Hi all,

I have a problem using torque for a table that has a foreign key to itself
(in order to implement tree structures).  This table in question has an
integer primary key.  I'm using oracle 8 as DBMS.

Insertion of a new record at the top level of a tree (with a null value for
the FK field), will throw an sql exception when using the standard .save()
method of the torque table class.  

In the archives I found somebody posted a workaround to this problem by
using the doInsert() method of the object's peer class, using a Criteria
object with the null inserted as FK.

Another thing I did was overloading the table class' save() method, to check
for a null value fk, and if so, use the workaround, otherwise use the
enherited save() method from the baseclass.

I was wondering if there is a more elegant solution to this problem?

Kind regards,

Nicolas

Mime
View raw message