db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bernardo Arlandis Mañó <bera...@ya.com>
Subject Problem with foreign keys
Date Tue, 21 Jan 2003 12:52:42 GMT
Hi, it's the first I post to this list. I've started doing development with 
turbine and torque and I have been able to do well by myself, but now I'm a 
little lost with this problem.

I'm using for my trainning the tdk2.2.1_01 which uses torque3.0.

I've defined something like this:

<database name="data">
   <table name="TABLE1">
     <column name="ID" required="true" primaryKey="true" type="INTEGER"/>
     <column name="NAME" required="true" size="32" type="VARCHAR"/>
   </table>
   <table name="TABLE2">
     <column name="ID" required="true" primaryKey="true" type="INTEGER"/>
     <column name="NAME" required="true" size="255" type="VARCHAR"/>
   </table>
   <table name="table3" idMethod="idbroker">
     <column name="ID" required="true" primaryKey="true" type="INTEGER"/>
     <column name="FK1" type="INTEGER"/>
     <column name="FK2" type="INTEGER"/>
     <foreign-key foreignTable="TABLE1" name="FK_FK1">
       <reference local="FK1" foreign="ID"/>
     </foreign-key>
     <foreign-key foreignTable="TABLE2" name="FK_FK2">
       <reference local="FK2" foreign="ID"/>
     </foreign-key>
   </table>
</database>

Doing it this way I get duplicated methods for the foreign key columns, one for 
the key and one another for the object. So I've tried taking away the column 
definitions of the foreign keys changing table3 like this:

   <table name="table3" idMethod="idbroker">
     <column name="ID" required="true" primaryKey="true" type="INTEGER"/>
     <foreign-key foreignTable="TABLE1" name="FK_FK1">
       <reference local="FK1" foreign="ID"/>
     </foreign-key>
     <foreign-key foreignTable="TABLE2" name="FK_FK2">
       <reference local="FK2" foreign="ID"/>
     </foreign-key>
   </table>

But now I get a NPE:

java.lang.NullPointerException
         at 
org.apache.torque.engine.database.model.Database.doFinalInitialization(Database.java:444)
         at 
org.apache.torque.engine.database.model.AppData.doFinalInitialization(AppData.java:313)
         at 
org.apache.torque.engine.database.model.AppData.getDatabase(AppData.java:221)
         at 
org.apache.torque.task.TorqueDataModelTask.initControlContext(TorqueDataModelTask.java:350)

I hope someone can give me a hint as I've been unable to find an explanation 
looking at the docs and examples.

Thank you.
Regards.

-- 
Bernardo


Mime
View raw message